What Is a CDN?
A CDN is a network of servers in different parts of the world that keep copies of your files, so a visitor downloads them from a machine near them rather than from wherever your site is hosted. If you are deciding whether one belongs in your stack, how to choose an image CDN covers the version built specifically for images.
Distance is the problem
Data moves fast, but not instantly. A request from Sydney to a server in Virginia crosses the Pacific, and buying more bandwidth does not shorten that trip. Bandwidth is about how much you can send at once, which is a different problem.
The delay also repeats. A browser loading a page makes dozens of requests, not one: the HTML first, then stylesheets, scripts, fonts, images, many of them waiting on each other. Multiply a small per-request delay across a page and a round trip of several thousand miles and you get a site that feels sluggish for reasons that have nothing to do with your code.
Putting a copy of the file in Sydney is how you fix that. The Sydney visitor stops crossing an ocean.
How a CDN works
CDN providers run servers in many locations, often called edge locations or points of presence. Each one can hold copies of your files.
The first time someone in a given region asks for a file, the nearby edge server usually does not have it. It fetches it from your origin server, hands it to the visitor, and keeps a copy. Everyone else in that region who wants that file gets the stored copy, and your origin never hears about those requests.
That first uncached request is a cache miss. Every subsequent one is a cache hit. A well-configured CDN turns the overwhelming majority of requests into hits, which is where both the speed and the reduced server load come from.
Copies do not live forever. Each file carries a time to live, and once it expires the edge checks with your origin again. When you need a change live immediately rather than whenever the timer runs out, you purge the cached copy and force a refresh.
You may already have one
Worth checking before you go shopping. A lot of hosting now includes CDN delivery by default rather than selling it separately. Static hosts and edge platforms typically serve everything through their own network as a matter of course, and many managed hosts put one in front of your site whether or not you asked.
If that describes your setup, static assets are already being distributed and the question is not whether to add a CDN but what is still slow despite having one.
Two things usually are. Pages that cannot be cached, because they are generated per visitor. And images, because a CDN moves them without shrinking them.
What a CDN does not fix
Plenty, and this gets oversold.
A CDN does not make your application faster. If a page takes two seconds because of a database query, it still takes two seconds, and there is nothing cached for the CDN to serve instead. Dynamic and logged-in pages get generated fresh every time more or less by definition.
It also does little for visitors already near your server. If your audience and your hosting are both in one city, you are not removing much distance.
And it does nothing about the size of what you send. A CDN will deliver a 4 MB photograph very efficiently, and it will still be 4 MB when it lands.
Where images come in
On most sites the biggest thing being sent is an image, and a plain CDN has no opinion about that. Whatever you upload is what every visitor downloads, whether they are on a phone with two bars or a desktop on fibre. Serving one large file to everyone wastes bandwidth on exactly the connections that can least afford it.
Handling that is a different job from distribution, and it needs different machinery. Image CDN vs regular CDN covers what separates the two.
Frequently asked questions
- What does CDN stand for?
- Content Delivery Network. It is a group of servers spread across many locations that hold copies of your site's files and serve them from whichever location is closest to each visitor.
- Do I need a CDN for a small site?
- If your visitors are near your server and your pages are light, probably not. A CDN earns its place when visitors are spread out geographically, when files are large, or when traffic arrives in bursts your server would struggle with.
- Does a CDN replace my web server?
- No. Your server remains the source of truth. The CDN keeps copies and serves those copies, returning to your server only when it needs something it does not have or something that has expired.
- What is an origin server?
- The machine where your real files live. Everything a CDN serves is a copy of something that came from the origin at some point.
- Will a CDN make my site faster?
- Usually, for visitors far from your server, because the data travels a shorter distance. It does less for visitors already close by, and nothing at all for slowness caused by your application code or database.