Your cache headers decide how hard your server works
A few response headers decide whether a traffic spike lands on your CDN or on your server. Set them well and a busy day feels like a quiet one; set them badly and every visitor waits while your server builds the same page again.
A page built on every request
When a page cannot be cached, every visit goes all the way to your server. A post shared on a busy forum becomes a thousand identical page builds in a minute, and the database feels each one.
A few headers cause this on their own. Cloudflare, for example, passes a response straight through, marked BYPASS, when it carries no-store, private, a Set-Cookie header or Vary: *. A page marked DYNAMIC was never looked up in the cache at all. A single session cookie set on every page is enough to make a whole site uncacheable at the edge.
The fix is usually small: send cookies only on the pages that need them, and give public HTML a short public lifetime instead of none.
Serve the old copy while the new one is made
Two Cache-Control extensions let a cache keep answering when a copy expires. stale-while-revalidate lets it hand out the expired copy while it fetches a fresh one in the background, so no visitor waits on your server. stale-if-error lets it keep serving the old copy when your server fails or cannot be reached, so a crash at the origin looks like a slightly older page instead of an error.
Cloudflare made stale-while-revalidate fully asynchronous on 2026-02-26: the first request after expiry already gets the old copy, marked UPDATING, while the refresh runs. A copy served because the origin was down is marked STALE.
Request collapsing matters just as much. When many visitors ask for the same expired page at once, the CDN sends one request to your server and shares the answer. Fastly has it on by default for misses, and its docs note that turning it off also turns off stale serving.
- A good start for public HTML: Cache-Control: public, max-age=60, stale-while-revalidate=600, stale-if-error=86400.
- If many pages share one lifetime and were cached together, they also expire together. Spreading lifetimes a little, often by about 10%, avoids that wave; it does not help a single hot page, which needs stale serving or collapsing.
max-age for browsers, s-maxage for the CDN
max-age tells every cache how long a copy is fresh. s-maxage applies only to shared caches such as a CDN, and overrides max-age there. That makes it tempting to give the CDN an hour and browsers a minute.
At Cloudflare that choice has a cost: s-maxage, must-revalidate, proxy-revalidate and no-cache all switch stale serving off, so an expired page is fetched while the visitor waits, marked EXPIRED. To give the CDN its own lifetime without that, use CDN-Cache-Control, which Cloudflare reads and passes on to other caches, or Cloudflare-CDN-Cache-Control, which it reads and removes.
Long CDN lifetimes also reach browsers in a surprising way. In HTTP Archive data from August 2026, covering about 15.3 million sites, about 13.7% served at least one response whose Age header was already past its max-age, often because the CDN's s-maxage was far longer than the browser's max-age. The browser receives a copy that is stale on arrival.
- HTML: minutes, or no-cache with validators. A year is the wrong advice for pages.
- Scripts, styles, fonts and images with versioned file names: a year, with immutable.
Validators make a refresh cheap
An ETag or Last-Modified header lets a cache ask your server whether its copy is still good. If nothing changed, the server answers 304 Not Modified with no body. The page is not rebuilt or sent again, and the check takes a fraction of the work.
Without either header, the only way to refresh is to fetch the whole page. Cloudflare fills the gap by using the time it cached the copy as Last-Modified. A response marked REVALIDATED means the visitor waited on one of these conditional checks, which is fast but still a trip to your server.
Vary decides how many copies exist
Vary names the request headers that change the answer, and a cache keeps a separate copy for each combination. Vary: Accept-Encoding is normal and cheap: a handful of copies, one per compression. Vary: Cookie or Vary: User-Agent can mean a copy per visitor or per browser build, which in practice means almost no hits. Vary: * means no copy can be reused, and Cloudflare treats it as uncacheable.
If a page really does change by a header, such as Accept for a Markdown version beside the HTML, vary on that one header and keep its values few.
See what your site actually does
Request the same page twice from a terminal with curl -sI and read Cache-Control, Age, ETag, Last-Modified and Vary. Your CDN adds its own verdict, such as cf-cache-status at Cloudflare or the standard Cache-Status header that Netlify sends. A second request that still says MISS or BYPASS is the page your server builds every time.
Good tools cover different parts of this. CDN dashboards show hits and misses from inside the network: Cloudflare Cache Analytics splits traffic by cache status and lists the URLs most often expired or revalidated, and Fastly reports cache coverage apart from hit ratio, which separates could it be cached from was it. Their numbers are sampled, so read them as close estimates. Lighthouse and PageSpeed Insights audit the cache lifetimes of scripts, styles, fonts and images. webhint judges HTML apart from assets and flags contradictions such as no-cache with max-age. REDbot explains a single response's cacheability and validation. CDN Planet and DebugBear's cache checker show one URL's cache status from many locations at once. Screaming Frog puts every header in its own column across a whole crawl.
Sites in the Woods reports this for each page it watches, over time: which pages are not cached, whether stale serving is on, how long pages are kept for browsers and the edge, whether copies arrive stale, which pages lack validators and which were cached together.
Sources
- RFC 9111: HTTP Caching · read
- RFC 9110: HTTP Semantics (validators, conditional requests, Vary) · read
- RFC 5861: HTTP Cache-Control Extensions for Stale Content · read
- RFC 9211: The Cache-Status HTTP Response Header Field · read
- Cloudflare: Cloudflare cache responses · read
- Cloudflare changelog: asynchronous stale-while-revalidate · read
- Cloudflare: Revalidation · read
- Cloudflare: Origin Cache Control · read
- Cloudflare: CDN-Cache-Control · read
- Cloudflare: Cache Analytics · read
- Fastly: Request collapsing · read
- Fastly: Edge metrics (cache coverage and hit ratio) · read
- Netlify: Cache-Status reference · read
- Resource age and its impact on cacheability (HTTP Archive data) · read
- Upstash: Redis TTL jitter · read
- Upstash: Thundering herd and cache stampede · read
- Chrome for Developers: Lighthouse, efficient cache policy · read
- webhint: http-cache · read
- REDbot · read
- CDN Planet: CDN performance check · read
- DebugBear: Website cache checker · read
- Screaming Frog: HTTP headers guide · read
Published .
Reading robots.txt, the homepage, llms.txt, Agent card, OpenAPI, MCP manifest, security.txt and the sitemap, the newer agent files and a few pages. Slow sites take up to 20 seconds.
Last updated .