What is s-maxage in Cache-Control?
s-maxage sets the freshness lifetime for shared caches such as CDNs only. It overrides max-age and Expires there, and browsers ignore it.
s-maxage is a `Cache-Control` response directive that sets the freshness lifetime, in seconds, for shared caches only, such as a CDN or a reverse proxy. For those caches it overrides both `max-age` and the Expires header. Private caches, such as the browser, ignore it.
Cache-Control: public, max-age=60, s-maxage=86400That header lets a browser keep the page for a minute while the CDN keeps it for a day. The split is useful for HTML: the edge can hold a page for a long time because you purge it on deploy, while browsers check back often.
Some platforms rewrite the header on the way out. Vercel, for example, strips s-maxage and stale-while-revalidate from the response it sends to the browser when you set them in Cache-Control without a CDN-Cache-Control. A targeted field is the explicit way to address a CDN.
Related terms
References
- RFC 9111: HTTP Cachinghttps://www.rfc-editor.org/rfc/rfc9111
- MDN: Cache-Controlhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
- Vercel: CDN Cachehttps://vercel.com/docs/caching/cdn-cache
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.