Find out what is slowing the page down
A CDN can shorten file downloads for distant visitors while leaving a slow page almost unchanged. The remaining delay may come from database queries, server rendering or scripts running in the browser.
Measure those stages separately. Caching and delivery help with some of them; others need changes to the application or page itself.
What a CDN is, in practice
A CDN is a network of servers spread across many regions. When a visitor in Singapore asks for your logo, the request goes to a nearby CDN server instead of crossing the planet to your origin server in Frankfurt. If that nearby server already has a copy, it answers straight away. If not, it fetches the file from your origin once, keeps it, and serves the next visitor from memory.
The gain comes from two things:
- Shorter distance. Every round trip between browser and server takes time, and that time grows with distance. A page needs many round trips, so cutting each one adds up.
- Less load on your server. Requests the CDN answers never reach your origin, which leaves more capacity for the requests that must.
What it caches well
Anything that is identical for every visitor and changes rarely:
- images, fonts, icons and video
- JavaScript and CSS bundles, especially when file names include a content hash
- static HTML pages such as blog posts, documentation and marketing pages
- downloadable files such as PDFs
What it cannot fix
- Slow server rendering. If your server needs two seconds to build a page from the database, a CDN can only help by storing the finished page. For pages that cannot be stored, those two seconds stay.
- Heavy JavaScript. A CDN delivers a large bundle faster, but the browser still has to download, parse and run all of it. On a mid-range phone that work often costs more than the download.
- Slow third-party scripts. Chat widgets, tag managers and ad scripts load from other servers. Your CDN has no say over them.
- Layout shifts. Content jumping around while it loads comes from how the page is built, not from where files are served.
If your main problem sits in this second list, start with rendering choices and script weight. Our article on choosing SSR, SSG or ISR per page covers the rendering side.
Cache headers in plain terms
A CDN does not guess what it may keep. Your server tells it through response headers, mainly Cache-Control. A few values cover most cases:
- A long max-age with immutable, for files whose name changes whenever their content changes. The CDN and the browser can keep them for a year, because a new version will have a new name.
- A short max-age or s-maxage, for HTML that changes now and then. The CDN keeps the page for a few minutes, then checks again.
- stale-while-revalidate, which lets the CDN serve the old copy instantly while it fetches a fresh one in the background, so visitors rarely wait for the refresh. Support for this directive varies by CDN and configuration, so check your provider's documentation and test it.
- private or no-store, for anything personal. The CDN must not keep it at all.
Invalidation
Sooner or later you change something that is already cached: a price, a typo on the home page, a product photo. You then have two options. Wait for the cache to expire, or purge it through the CDN's interface or API.
Purging everything is the blunt tool and it works, but it sends a wave of traffic to your origin as every copy refills at once. Better setups purge by path or by tag, so updating one product clears only the pages that show it.
The cleanest approach for assets is to avoid invalidation entirely. Put a content hash in the file name, and a new build simply produces new file names. Old copies age out on their own.
Images at the edge
Many CDNs can resize and convert images on the fly. The page asks for an image at a given width, and the CDN produces a version in that size and in a modern format such as WebP or AVIF, then caches the result.
This is often the single biggest win a CDN offers, because images are usually the heaviest part of a page. Two cautions:
- Make sure the original images are not absurdly large to begin with. Converting a huge file on every cache miss is slow.
- Keep the number of size variants small. Every distinct width is a separate cache entry, and a handful of standard sizes caches far better than any width a script happens to request.
Effect on Core Web Vitals and global visitors
For visitors far from your server, a CDN usually improves time to first byte and the Largest Contentful Paint, especially when the largest element is an image or the page itself can be cached. Visitors close to your origin will see a smaller gain, sometimes almost none.
It does little for Interaction to Next Paint, which depends on how much JavaScript runs in the browser, and nothing for Cumulative Layout Shift.
So if your audience is spread across countries, a CDN is close to mandatory. If you are still on shared hosting and wondering whether a CDN is enough to keep going, our piece on moving from shared hosting to a VPS or the cloud helps with that decision. If nearly all your users live near your server and your pages are rendered per request, expect modest results and look at rendering and script weight first.
The mistakes that serve the wrong page
The dangerous CDN problems are not slowness. They are correctness.
Caching personalized pages
A page with "Hello, Anna" in the header gets cached, and the next visitor sees Anna's name. With carts or account pages this becomes a privacy incident. Anything that depends on a cookie or login must be private, or the CDN must be told explicitly to keep separate copies per variant.
Stale prices and stock
A product page cached for an hour shows yesterday's price after a sale ends, or "in stock" after the last item sold. Either cache those pages for a short time with revalidation, or load price and stock separately from an uncached endpoint while the rest of the page stays cached.
Region and language mix-ups
If your server picks the language or currency from the visitor's location, but the CDN caches the first answer for everyone, a German visitor may get a page in English with prices in dollars. Separate URLs per region are far more reliable than detection behind a cache.
Caching errors
A brief outage at your origin returns error pages, the CDN caches them, and the site stays broken after your server recovers. Configure error responses with a very short cache time or none at all.
How to check it is working
Do not trust the dashboard alone. A few quick checks tell you more:
- Read the response headers. Open the browser's network panel and look at a static file and an HTML page. Most CDNs add a header showing a cache hit or miss. Reload a couple of times: the second request should be a hit.
- Check the cache rules match your intent. Confirm that pages with personal data come back as private or not cached at all.
- Test from far away. Use a speed test tool that lets you pick a location on another continent. That is where a CDN should make the clearest difference.
- Watch the hit ratio. If most requests still reach your origin, your headers are probably too strict or your URLs vary needlessly, for example through tracking parameters.
- Purge one page and watch it refresh. It confirms your update process works before you need it on a busy day.
Measure from several locations
Measure first. Run a speed test from two or three locations and note where the time goes: waiting for the server, downloading files, or running scripts in the browser.
If downloads and distance dominate, a CDN with sensible cache headers and image optimization can reduce loading time. If the server or the scripts dominate, the CDN is still worth having, but the real work is elsewhere. That mix of caching, rendering and script work is the kind of foundation our technical SEO service is built around.


