Skip to main content
sitewarm
HTTP caching headers

What is the Cache-Control header?

Cache-Control is the HTTP header that tells browsers and CDNs whether a response may be stored, for how long, and when it must be revalidated.

Cache-Control is the HTTP header that carries caching directives in requests and responses. On a response, it tells every cache on the path, from the browser to a CDN, whether the response may be stored, how long it stays fresh, and what to do once it is stale. RFC 9111 defines it.

Cache-Control: public, max-age=60, s-maxage=3600, stale-while-revalidate=30

Directives are comma-separated and case-insensitive. The ones that matter most for a CDN are:

A CDN can also read a targeted field such as `CDN-Cache-Control`, which overrides Cache-Control for that CDN only. Many CDNs also apply their own defaults on top of the header: Cloudflare, for example, does not cache HTML by default. Check what your CDN actually does with the cache status it returns, not only with the header you send.

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.