Skip to main content
sitewarm
HTTP caching headers

What does Cache-Control must-revalidate do?

must-revalidate forbids a cache from serving a stale response without checking the origin first. If the origin is down, the cache returns an error.

must-revalidate is a `Cache-Control` response directive. Once the response is stale, a cache must not reuse it until it has revalidated it with the origin. If the cache cannot reach the origin, RFC 9111 says it must return an error rather than serve the stale copy, and that the status should be 504 Gateway Timeout.

Cache-Control: max-age=300, must-revalidate

While the response is fresh, must-revalidate changes nothing. It only removes a cache's freedom to serve stale content, which HTTP otherwise allows in some cases, such as when the cache is disconnected from the origin.

  • It turns off `stale-while-revalidate` and `stale-if-error` in practice, because both serve stale responses without validation.
  • proxy-revalidate is the same rule for shared caches only, and `s-maxage` implies it.
  • RFC 9111 suggests using it only when serving stale content could cause incorrect operation. For most public pages, revalidation with an `ETag` and a stale window keeps pages available when the origin is down.

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: Revalidationhttps://developers.cloudflare.com/cache/concepts/revalidation/

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.