The CDN dashboard says caching is enabled. The origin logs say every request is still arriving. That gap usually has three causes: a header that forbids storage, a cache key that changes on every request, or a purge routine that undoes itself.
This guide works from symptom to cause to fix, then to the routine that prevents a repeat. It assumes you can see response headers and cache status.
Five checks before you change a setting
- Read the response. Inspect status,
Cache-Control,Age,Vary,Set-Cookieand the provider cache-status header from two locations. - Confirm the request is cacheable. POST requests, requests with authorisation headers and responses that set cookies are usually excluded by design.
- Write down the cache key. Host, path, query string, cookies, device, country and language may all be part of it.
- Verify the edge is in front of the right origin. DNS records, proxy status, certificate and origin host header are common faults after a migration.
- Find the change. A new deploy, DNS edit, certificate renewal or rule change is more likely than a sudden provider defect.
Symptom: the hit ratio never rises
Likely cause. HTML responses carry Cache-Control: no-store or private, the application sets a session cookie on every page, or marketing tags append unique query parameters. A Vary: * header has the same effect as disabling the cache.
Fix. Separate content into classes. Static assets get long lifetimes with content-hashed filenames. Public category and product pages get a short shared lifetime. Account, cart and checkout pages bypass the shared cache. Remove tracking parameters from the cache key where the application does not use them.
Prevention. Add a response-header test to the release checklist for one page per class.
Symptom: visitors see an old page after a deploy
Likely cause. HTML is cached for hours or days, the purge did not reach every edge location, a service worker is serving the previous shell, or the browser itself is holding a stale copy.
Fix. Purge by tag or URL rather than purging everything, then verify the cache status header from a second network. Give HTML a short lifetime and put long lifetimes on versioned assets. If a service worker exists, ship a new worker and confirm it takes control.
Prevention. Version asset filenames, tag responses by release, and make purge part of deployment.
Symptom: a customer sees another customer's cart
Likely cause. Personalised HTML reached a shared cache, the edge stripped or ignored session cookies, or an application-level page cache stored a rendered page without the customer key.
Fix. Treat cart, account, checkout and order confirmation as private. Bypass the shared cache, or cache only fragments that contain no customer data. Test with two simultaneous accounts, not one browser with a cleared cookie.
Prevention. Keep an automated two-session test in the release pipeline.
Symptom: the wrong currency, language or device variant
Likely cause. The variant is chosen in the browser, but the edge caches one response and serves it to everyone. Alternatively, the cache key includes a header that almost never repeats, such as the full user agent.
Fix. Put the variant in something stable and visible, such as the path or a normalised cookie, and include it in the cache key. Normalise user agent to a small set of device classes rather than caching the raw string.
Prevention. Test each variant from a clean session after every caching change.
Symptom: images, fonts or scripts break after switching the CDN
Likely cause. Hotlink protection, a missing CORS header for fonts, mixed content, a path rewrite that changes the asset URL, or signed URLs that expire before the page loads.
Fix. Compare the asset URL in the page source with the URL the browser requests. Check the response status and the Access-Control-Allow-Origin header. Keep signed URL lifetimes longer than the longest page session, or move public assets to unsigned paths.
Prevention. Add a synthetic check for the home page, a product page and checkout through the CDN.
Symptom: the origin is hammered at the same time every hour
Likely cause. Many objects share the same expiry, a scheduled job purges everything, or a popular page expires and every edge location requests it at once. There is no request collapsing.
Fix. Add jitter to lifetimes, enable stale-while-revalidate where the provider supports it, turn on request collapsing or origin shield, and stagger purge jobs.
Prevention. Monitor origin requests per minute against cache status, not just average hit ratio. Peaks reveal stampedes that averages hide.
Symptom: the site is slower with the CDN than without it
Likely cause. Visitors are routed to a distant edge, the edge opens a new TLS connection to the origin on every request, compression is applied twice, or dynamic pages that cannot be cached now take an extra hop.
Fix. Measure time to first byte by location and by cache status. Enable keep-alive and HTTP/2 or HTTP/3 to the origin, move compression to one layer, and check that redirects are not looping through the edge.
Prevention. Keep a baseline from your main customer locations before and after any CDN change.
Symptom: purge works, then the old version returns
Likely cause. There is more than one cache in the path: browser, service worker, CDN, origin page cache or a second CDN in front of the first. The purge only reached one of them.
Fix. Map the full request path and invalidate each layer. Confirm that staging and production do not share a cache key or hostname. Check that tag-based purges match the tags actually emitted.
Prevention. Draw the cache layers in the runbook and give each one an owner and an invalidation method.
The order that saves time
Reproduce the fault with a command-line request from two locations. Read the headers before touching the dashboard. Confirm the cache key, check the purge history, then inspect the origin page cache and any service worker. Change one setting and measure again; three changes at once produce a result nobody can attribute.
What not to do under pressure
Disabling caching for the whole site makes the symptom disappear and the origin fall over. Purging everything repeatedly hides the real invalidation bug. Adding random query strings to asset URLs defeats the cache permanently.
A prevention routine
- Classify content and record the intended policy for each class.
- Test headers and variants after every release.
- Review hit ratio and origin request peaks weekly, and run a purge drill monthly.
Metrics to watch
Cache hit ratio by content class, origin requests per minute, time to first byte by location, origin 5xx rate, purge latency and cache-related support tickets. Add checkout completion if the CDN sits in front of a store, because a caching fault at payment is a revenue event.
Where this fits in our work
Caching and edge configuration are part of Managed Technology & Cybersecurity, alongside managed infrastructure protection and monitoring. The pricing page sets out how reviews and ongoing care are scoped. For the policy design behind these fixes, use the CDN caching strategy checklist.
Sources
- IETF, RFC 9111: HTTP Caching, accessed 17 November 2026.
- MDN Web Docs, Cache-Control header, accessed 17 November 2026.
- Cloudflare, Cache documentation, accessed 17 November 2026.
- web.dev, HTTP caching, accessed 17 November 2026.
Responses (0)
No comments yet. Add the first one below.
Leave a response
Your email address will not be published. Required fields are marked *.