Cache key hygiene: the cheapest 40 ms you'll ever ship
Every CDN caches on a key. That key is usually the URL, but on real sites it also includes headers, cookies, query strings, and sometimes the moon phase. When the key is too specific, cache hit rate collapses. When it's too permissive, you serve someone else's session-scoped HTML.
The three cache-key mistakes we see every week
- Every query string variant is a new key. UTM parameters, Facebook click IDs, and internal analytics tags mint a new cache entry for every visitor.
- Cookies as a cache dimension. If your CDN varies on
Cookie, you're caching per-visitor. Congratulations, you have a very expensive reverse proxy. - Vary: * or Vary: User-Agent. These effectively disable caching. If you see them in your origin response, delete them.
What good looks like
For a marketing page, the ideal cache key is method + host + path + (a small, closed list of relevant query params). Everything else should be stripped before the key is computed. Most modern CDNs (Cloudflare Cache Rules, Fastly VCL, CloudFront cache policies) let you do this declaratively.
Measure before and after
Look at your cache hit ratio broken down by URL pattern. If your top-10 pages have hit rates below 90%, you're leaving money on the table. Fix the key, then wait 24 hours — the numbers usually move in one release cycle.
This is exactly the kind of quick-win we knock out in the first week of a Managed Edge engagement.
Want us to run this for you?
Tell us your stack and we'll come back with a scoped engagement within one business day.