What a CDN does, and whether your site needs one
A content delivery network serves copies of your files from near each visitor. What it caches, what it can't, when you need one and how to check it works.

A content delivery network, or CDN, is a set of servers in many cities that keep copies of your website's files and hand each visitor the copy nearest to them. Your own server, called the origin, still holds the real site. The CDN answers the requests it can from its copies, and passes the rest back to your origin.
That one idea explains everything a CDN is good at, and everything it can't do. This article goes through what gets copied and what doesn't, what a CDN does for speed and for staying online, when a small site can do without one, and how to check yours is actually working.
Serve the copy nearest the visitor#
Every file a browser fetches makes a round trip: the request travels to the server and the reply travels back. Distance sets a floor on how long that takes. A visitor in Manchester asking a London server for a file waits a few milliseconds. A visitor in Sydney asking the same server waits far longer, on every round trip, and a page needs several before it appears.
A CDN shortens the trip. Its servers, usually called edge servers or points of presence, sit in data centres around the world. When a visitor asks for your logo, the request goes to the nearest edge. If that edge already holds a copy, it replies at once. If it doesn't, it fetches the file from your origin, sends it on, and keeps a copy for the next visitor. Keeping a stored copy like this is called caching.
The saving is largest when your visitors are a long way from your origin. It's smallest when they're already close to it, which matters for the question at the end of this article.
Know what a CDN can and can't cache#
A CDN can only hand out a copy if every visitor should get the same file. That splits a website in two.
Files that are the same for everyone cache well. Images, stylesheets, scripts and fonts are the obvious ones, and they're most of the weight of a typical page. Many CDNs cache these by default, recognising them by their file extension.
The page itself, the HTML, is a decision. A blog post or a service page is usually the same for everyone, so it can be cached. Many CDNs won't do it unless you ask; Cloudflare's documentation, for example, says HTML isn't among the file types it caches by default. Caching the HTML is what turns a CDN from a faster way to deliver images into a faster way to deliver the whole site, because it takes your server's thinking time out of the wait. That thinking time is a large part of what time to first byte measures, alongside the time spent connecting.
Anything personal must never be cached. Baskets, checkouts, account pages and anything shown to a logged-in user belong to one person. A CDN that stored one of those and handed it to the next visitor would show a stranger somebody else's order. Your origin tells the CDN what's safe with a header called Cache-Control, which says whether a reply may be stored, for how long, and by whom; MDN's reference lists every setting. WordPress shops and membership sites need these rules set carefully, and a good host or plugin sets them for you. Prices that change by visitor are a version of the same problem, and showing per-visitor prices on a cached site goes through one way round it.
Cached copies also need clearing when you change something. Most CDNs let you purge a single address or everything at once, and most hosting control panels and WordPress caching plugins can do it for you each time you publish.
A CDN can only hand out a copy when every visitor should get the same file.
Keep the site up when your origin struggles#
Speed is the reason most people give for a CDN, but the bigger gain for a small business is often what it does under pressure.
It takes the load. When a post does well or a mailing goes out, the edges answer most of the extra requests and your origin only sees the misses. A server that would have buckled under the traffic barely notices it.
It absorbs attacks. A denial-of-service attack floods a site with traffic until it can't answer real visitors. A large CDN has far more capacity than any single server, and most filter the worst floods before they reach you. Many CDNs also offer a web application firewall, a filter that blocks requests that look like known attacks.
It can cover a short outage. Some CDNs can keep serving the stored copy of a page when the origin stops answering, if you've turned that on. Visitors reading your service pages may never notice; anyone trying to buy or log in will, because those pages were never cached.
Two cautions. The protection only works if attackers can't go round it, so your origin should accept web traffic only from the CDN. And the CDN becomes something your site depends on: when a large CDN has had a provider-wide fault, thousands of sites have gone offline at once, whatever state their own servers were in.
Let your host or CDN choose HTTP/2 or HTTP/3#
HTTP is the set of rules a browser and a server use to ask for and send files. Its versions change how those files travel, not what's in them.
HTTP/2, published in 2015, lets one connection carry many files at once. The older HTTP/1.1 sent one file at a time on each connection, so browsers opened several connections and still queued. HTTP/2 also compresses the headers that go with every request.
HTTP/3, published in 2022 as RFC 9114, runs over a newer transport called QUIC instead of TCP. On HTTP/2, one lost packet holds up every file on the connection until it's resent; on HTTP/3 it holds up only the file it belonged to. HTTP/3 also sets up a secure connection in fewer round trips, and a connection can survive a phone moving from Wi-Fi to mobile data. The difference shows most on weak mobile connections and least on a good office line.
You don't choose the protocol, and nothing in your pages changes it. The browser and the server settle it between them. A first visit usually starts on HTTP/2, the server says HTTP/3 is available, and the browser switches to it for later requests. If your site sits behind a CDN, the visitor's connection is to the edge, so the CDN's settings decide; most large CDNs offer HTTP/3, often as a switch in the dashboard. The CDN's connection back to your origin is a separate one with its own setting. To see what visitors get, open your browser's developer tools, go to the Network panel and show the Protocol column: h2 is HTTP/2 and h3 is HTTP/3.
Check the cache headers to see it working#
A CDN that's set up but never serving from its copies is just an extra stop on the way to your server. The headers on each reply tell you which happened.
Open your developer tools, reload the page, click on a request and look at its response headers. Cloudflare adds cf-cache-status: HIT means it came from the stored copy, MISS means it was fetched from your origin and stored, DYNAMIC means its default rules don't treat that file as cacheable, and BYPASS means a rule or a header from your site told it to skip the cache, which is right for baskets and account pages. Amazon CloudFront uses x-cache, with values such as Hit from cloudfront. Many caches also send Age, the number of seconds the copy has been stored.
Reload a second time before you judge. A first request is often a miss, because that edge hadn't been asked before. If images stay on MISS after several reloads, or the page you meant to cache always says DYNAMIC, the rules need looking at. Our free website checkup also reads a site's headers, including the security headers covered here, if you'd like a second look.
Skip it when your visitors are close by#
Plenty of small British businesses don't need a CDN for speed. If nearly all your customers are in the UK and your host's servers are in London, every visitor is already a short trip from the origin. A well-built site on decent hosting with its pages cached on the server will feel quick without one.
A CDN earns its place when your visitors are spread across countries, when your traffic comes in sudden spikes, or when you want the attack filtering in front of your site. Several CDNs have a free tier that covers a small site's static files, so the cost is often setup time rather than money. The one thing a CDN can't fix is a page that's slow because the server takes too long to build it and the page can't be cached. That needs work on the server or the site itself.
In summary#
A CDN keeps copies of your files near your visitors and answers from them, so the distance to your origin stops being the visitor's problem. It speeds up what's the same for everyone, never what's personal, and takes load and attacks off your server. HTTP/2 and HTTP/3 are settings your host or CDN looks after for you. Check the cache headers to make sure the copies are being used, and if your customers are all near your server, decide whether you need one at all.
Free speed test
See how fast your own site is, scored the way Google scores it, and what to fix first.
Free
Test your site

