CDN Performance Explained: Edge Caching, Cache Misses, Latency and When a CDN Cannot Help

How an edge request works, why cache keys cause accidental misses, and the cases where a CDN adds complexity without adding speed.

In short

A CDN keeps copies of your files on servers around the world, so visitors download them from somewhere nearby instead of from your origin. For static files — images, CSS, JavaScript, fonts — it is close to a free win.

The two things worth understanding before you buy one:

A CDN helps with distance, not with slowness. If your origin takes 1.5 seconds to build a page, a CDN that cannot cache that page adds a hop and delivers the same 1.5 seconds. It is a delivery optimisation, not a server optimisation.

A cache you are missing is a cache you are paying for. Most disappointing CDN results come from cache keys that vary unnecessarily — on query strings, cookies or headers — so almost every request goes to the origin anyway.

How a CDN request actually works

  1. The visitor's DNS resolves your hostname to the nearest point of presence (PoP).
  2. The edge server computes a cache key for the request — usually the hostname, path, and some set of query parameters and headers.
  3. If it has a fresh copy for that key, it returns it. Cache HIT.
  4. If not, it fetches from your origin, stores the result, and returns it. Cache MISS.
  5. The stored copy is reusable until its TTL expires.

Everything that goes wrong with a CDN goes wrong in step 2 or step 5.

Reading hits and misses

Every CDN reports this in a response header. The names differ:

curl -sI https://example.com/assets/app.js | grep -iE "cache|age|x-served"
HeaderCDN
cf-cache-status: HITCloudflare
x-cache: Hit from cloudfrontCloudFront
x-cache: HITFastly, Akamai and others
age: 3600Any — seconds since the edge stored it

What you should see: HIT on a second request for a static asset, and an age that increases. A MISS on every request means nothing is being cached.

Request the same URL twice. The first may legitimately be a MISS at that PoP; the second should not be.

Why cache misses happen

Cache keys that vary unnecessarily

The most common cause by a wide margin.

Query strings. If the key includes the full query string, then /image.jpg?utm_source=newsletter and /image.jpg?utm_source=twitter are two separate cache entries for the same file. Marketing parameters alone can fragment your cache into thousands of copies, each needing its own origin fetch.

The fix is to tell the CDN which parameters actually matter — usually none, for static assets — and ignore the rest.

Cookies. Many CDNs will not cache a response that sets a cookie, or will vary the key by cookie. An analytics cookie set on every response can disable caching for your entire site.

Vary headers. Vary: User-Agent is the classic mistake — it creates a separate cache entry per browser version, which is effectively no cache at all. Vary: Accept-Encoding is correct and necessary; Vary: Cookie or Vary: User-Agent usually is not.

TTLs that are too short

A five-minute TTL on an asset that never changes means twelve origin fetches an hour per PoP. With fingerprinted filenames you can safely use very long TTLs — see browser caching for why fingerprinting is the prerequisite.

Too many PoPs, not enough traffic

Each PoP keeps its own cache. A site with modest traffic spread across many locations may find each PoP's copy expiring before it is reused, so the hit ratio stays low.

Origin shielding addresses this: a designated PoP sits between all the others and your origin, so a miss at one edge is often a hit at the shield rather than a trip to your origin.

Content that genuinely cannot be cached

A cart page, a logged-in dashboard, a personalised recommendation block. These are correctly uncacheable, and that is fine — just do not expect the CDN to improve them.

When a CDN will not help

Being honest about this saves money and disappointment.

Your origin is slow for every request. A CDN cannot cache its way out of a 1.5 second server response on an uncacheable page. Fix TTFB first.

Your pages are personalised per user. Little to cache.

Your audience is in one city, next to your origin. The distance problem you are paying to solve does not exist.

Your problem is the browser, not the network. If your page is slow because of JavaScript execution or render-blocking CSS, delivery speed is not your constraint.

You are on a hosted platform. Shopify, Wix, Squarespace, Webflow and similar include a CDN you cannot choose or configure. Adding another in front is usually unhelpful and occasionally harmful — see the platform permission matrix.

And what it costs you

A CDN is not free of downsides:

  • A second cache layer to reason about. "Is this stale in the browser, at the edge, or on the origin?" becomes a regular question.
  • Purging to manage. With fingerprinted assets you rarely need it; without, you will.
  • A new failure mode. A misconfigured rule can serve the wrong content, or one visitor's personalised page to another.
  • Debugging gets harder. You are no longer looking at your own server's behaviour.

For most sites with a geographically spread audience, the trade is clearly worth it. For a local business with a fast origin, it may not be.

Caching HTML at the edge

Most people cache only static assets. Caching HTML too is where the large wins are, and where the risk is.

It works well when pages are the same for everyone, which is true of most content and category pages. The patterns that make it safe:

  • Cache by page type, not site-wide. Articles and collections yes; cart, account and checkout never.
  • s-maxage lets you cache longer at the edge than in the browser, so visitors get fresh HTML while the edge absorbs the load.
  • stale-while-revalidate serves the stale copy instantly while refreshing in the background — excellent perceived performance.
  • Purge on publish, so editorial changes appear immediately.

This is the single biggest thing a CDN can do for a content site, and it must be introduced carefully with a clear exclusion list.

Verifying it

  1. Hit ratio, from your CDN's own analytics. This is the headline number. A static-asset hit ratio below about 90% deserves investigation.
  2. Request the same URL twice and confirm the second is a HIT with an increasing age.
  3. Compare timing by region — a tool that lets you test from several locations should show much smaller differences than before.
  4. Check what is not being cached, and confirm each is deliberate.
  5. Confirm nothing personalised is cached publicly. Browse as two different signed-in users.
  6. Check Vary on your responses — Accept-Encoding is fine; User-Agent or Cookie usually is not.
  7. Verify compression is applied on misses too, not only at the edge.

Common mistakes

Expecting it to fix a slow origin.

Ignoring the hit ratio, and tuning everything except the thing that matters.

Letting marketing query parameters into the cache key.

Vary: User-Agent, which fragments the cache into uselessness.

A cookie set on every response, disabling caching site-wide.

Short TTLs on fingerprinted assets that could safely cache for a year.

Caching personalised pages publicly. The dangerous one.

Adding a CDN in front of a platform that already has one.

Compressing only at the edge, so misses are uncompressed.

Purging everything on every deploy, which empties a cache you just spent a day filling.

When it still does not help

  • Hit ratio is low → inspect the cache key. Query strings, cookies and Vary are the three causes, in that order of likelihood.
  • High hit ratio and no improvement → your bottleneck is not delivery. Check server response time and browser-side work.
  • Fast in some regions, slow in others → that region's PoP may be cold, or routing may not be sending traffic where you expect. Origin shielding helps.
  • Stale content after a deploy → purge, and then fix the underlying cause by adding fingerprinting.
  • A visitor saw someone else's data → stop and audit your cache rules immediately. Anything personalised must be private or no-store.
  • Only the first visitor in each region is slow → normal cold-cache behaviour. Origin shielding or pre-warming reduces it.

Keeping it working

CDN configuration drifts: a rule added for one campaign, a new cookie from a new tool, a new route that should have been excluded and was not.

Three habits: watch the hit ratio as a monitored metric rather than something you check when worried; keep a written list of what is deliberately uncacheable and review it when routes are added; and test personalised pages through the CDN as two different users after any rule change, because that is the failure with real consequences.

Frequently asked questions

Will a CDN make my website faster?

For static files served to a geographically spread audience, almost always. For a slow, uncacheable, personalised page, no — a CDN helps with distance, not with slowness. If your origin takes 1.5 seconds to build a page the CDN cannot cache, it adds a hop and delivers the same 1.5 seconds.

Why is my CDN cache hit ratio low?

Three causes, in order of likelihood: cache keys varying on query strings, so marketing parameters create thousands of separate entries for the same file; a cookie set on every response disabling caching; and a Vary header such as User-Agent that fragments the cache into uselessness.

How do I tell if a request was a cache hit?

Check the response header — cf-cache-status on Cloudflare, x-cache on CloudFront and Fastly, plus an age header counting seconds since the edge stored it. Request the same URL twice; the second should be a HIT.

Should I add a CDN in front of Shopify or Wix?

No. Those platforms include a CDN you cannot choose or configure, and adding another in front is usually unhelpful and occasionally harmful.

Can I cache HTML at the edge?

Yes, and it is where the largest wins are for a content site — but it needs care. Cache by page type with a clear exclusion list, never cache cart, account or checkout, use s-maxage to cache longer at the edge than in the browser, and purge on publish.

What does a CDN cost me, besides money?

A second cache layer to reason about, purging to manage, harder debugging, and a new failure mode — a misconfigured rule can serve one visitor’s personalised page to another. For a spread audience the trade is clearly worth it; for a local business with a fast origin it may not be.

References