Examples:
- Fingerprinted URLs
- Want: allow intermediate caches (not only browser) to cache for a year and after that revalidate with ETag
- Use:
Cache-Control: public, max-age=31536000and configureETagheader in server's responses
- Mutable content
- Want: Always revalidate with ETag
- Use:
Cache-Control:no-cacheAND configureETag`
What's the difference between no-cache vs must-revalidate + max-age?
no-cacherequires client to ALWAYS check if content is fresh (e.g., withETagorLast-Modified)must-revalidate+max-ageallows the cache to serve cached content untilmax-ageis reached
Why using Cache-Control: must-revalidate, max-age=600 is a bad idea for mutable content?
If that Url serves an Html that fetches additional assets (e.g., Js, Css) with the same cache strategy, the cache may load Html and Css and the server may load Js which refers to the newer (not cached) Html and Css.
Source: Prevent unnecessary network requests with the HTTP Cache