Skip to main content
sitewarm
HTTP caching headers

What does Cache-Control immutable mean?

immutable tells clients a response will not change while it is fresh, so they skip revalidation, even on reload. Use it for fingerprinted assets.

immutable is a `Cache-Control` extension, defined in RFC 8246, that promises the response will not change during its freshness lifetime. Clients should not send a conditional request for it while it is fresh, even when the user reloads the page. Only a forced reload overrides that. Once stale, it is revalidated as usual.

Cache-Control: public, max-age=31536000, immutable

It fits files whose URL changes whenever their content changes, such as app.3f9a1c.js. A new build gets a new URL, so the old one never needs to be checked.

  • It never fits HTML. The page URL stays the same across deploys, so a browser would keep an outdated page until `max-age` runs out.
  • Fingerprinted assets are rarely what a deploy leaves cold. The HTML that references them is, which is why cache warming targets pages.
  • On a CDN, a long TTL on these files is safe: they never need a purge.

References

  1. RFC 8246: HTTP Immutable Responseshttps://www.rfc-editor.org/rfc/rfc8246
  2. MDN: Cache-Controlhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control

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.