Skip to main content
sitewarm
HTTP caching headers

What does Cache-Control no-cache mean?

no-cache lets a cache store a response but requires it to revalidate with the origin before every reuse. It does not mean do not cache.

no-cache is a `Cache-Control` directive that allows a cache to store the response but forbids reusing it without first validating it with the origin. Despite the name, it does not mean do not cache: the stored copy and its validators make each check cheap. To forbid storage, use no-store.

Cache-Control: no-cache
ETag: "v42"

With a validator such as an `ETag` or `Last-Modified`, the cache sends a conditional request. If nothing changed, the origin answers 304 Not Modified with no body, and the cache serves its stored copy. The origin still sees every request, so no-cache saves bandwidth, not origin round trips.

  • no-cache versus `no-store`: the first stores and revalidates, the second never stores.
  • no-cache versus max-age=0 with `must-revalidate`: very close in effect. Both force validation before reuse.
  • With a field name, as in no-cache="Set-Cookie", the cache may reuse the rest of the response but must not send that header field without revalidation.

Cloudflare does not cache a response whose Cache-Control is no-cache by default, so a no-cache page served through it will report a miss or bypass rather than a hit.

References

  1. RFC 9111: HTTP Cachinghttps://www.rfc-editor.org/rfc/rfc9111
  2. MDN: Cache-Controlhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
  3. Cloudflare: Default cache behaviorhttps://developers.cloudflare.com/cache/concepts/default-cache-behavior/

Warm your cache after every deploy

sitewarm requests the pages in your sitemap after a deploy and reports the cache state the CDN returns for each one, with the vantage point it was measured from.