What is a CDN?
Definition
A CDN (content delivery network) is a set of servers around the world that keep copies of popular files close to the people opening them. The result is faster loading and less strain on the original server.
Also called: Content delivery network, Content distribution network, Edge network, Edge cache
How does a CDN work?
A CDN works by keeping copies of files on many servers, called edge servers, in cities around the world. The first time someone near an edge server asks for a file, that server fetches it from the host's main server, called the origin, and keeps a copy. The next person nearby gets the copy straight from the edge.
How long a copy stays is set by caching rules the origin sends with each file. A logo might be cached for a year, and a page that changes often for a few seconds or not at all. When a file changes, the host can tell the CDN to drop its old copies, which is called purging.
Why does a CDN make files load faster?
A CDN makes files load faster mainly by shortening the distance data travels. Each round trip between Sydney and a server in Virginia takes a noticeable fraction of a second, and loading a big file takes many round trips. An edge server in the same region answers far sooner, which matters most for images, video and large downloads.
It helps the host as well:
- The origin handles far fewer requests, so a sudden rush, such as a link going viral, is easier to absorb.
- Video starts and seeks faster, because the player fetches each piece from a nearby server.
- Many CDNs can filter abusive traffic and block hotlinking from other sites before it reaches the origin.
Can a CDN serve private files?
Yes, but only if access is checked before a copy is handed out. A CDN is built to give the same file to everyone who asks, so a cached copy of a private file could reach people it was never meant for. Hosts avoid this by caching only public files, or by requiring a signed URL or token for each private request.
For a password-protected link the order matters. The host checks the password first, then gives the browser a short-lived address on the CDN. Turn the link off and no new addresses are issued, while the old ones expire.
| Content | Cache it on a CDN? | Why |
|---|---|---|
| Images, video, fonts, scripts | Yes | The same for everyone, and often large |
| Public pages that rarely change | Yes, for a short time | Fast loads, refreshed when updated |
| Files behind a password or email gate | Only with short-lived signed access | The check must run before every open |
| Dashboards and account pages | No | Different for each signed-in person |
CDN: common questions
Is a CDN the same as cloud storage?
No. Cloud storage is where the original file lives. A CDN keeps temporary copies of it closer to the people opening it, and fetches a fresh copy from the origin when its own runs out.
Does a CDN keep my file after I delete it?
A cached copy can stay on some edge servers until its cache time runs out or the host purges it. Hosts that check access on every open, or hand out short-lived addresses, stop a deleted file from opening even if a copy lingers.
Does a CDN make uploads faster?
Not much. A CDN speeds up files that many people fetch, while an upload is a single trip to storage, so its speed depends mostly on your own connection.
Why do I still see the old version of a replaced file?
Your browser or the CDN may still hold the old copy for a short while. Reloading the page or waiting a few minutes usually fixes it, and hosts that give each version a new address avoid the problem.
Related terms
- Signed URLA signed URL is a temporary address for a stored file with a cryptographic signature and an expiry time built in. It lets a browser fetch one specific file for a few minutes, so the storage itself never needs to be public.
- HotlinkingHotlinking is showing another site's image, video or file on your own page by linking straight to its file address. The file loads from the other site's server, so that site pays for the bandwidth and usually never agreed to it.
- File hostingFile hosting is keeping a file online at a stable address so people can open it whenever they like, often in the browser. It suits files you share again and again: a resume, a menu, a price list.
- Cloud storageCloud storage is a private online drive for your own files, synced across your devices. Sharing is a side feature, so links often open the storage app's own viewer or ask the visitor to sign in.
- Static siteA static site is a website made only of ready-made files (HTML, CSS, JavaScript and images) with no server code or database. You can publish one by uploading a ZIP of the folder.
Go deeper
Updated