Andy Hume
Andy Hume

Reputation: 41674

Does Cache-Control s-maxage header override Expires header for browser cache?

I want to set a far future Expires headers to reduce requests made from individual browsers.

I'd also like to set Cache-Control: s-maxage=600 so that proxy caches (and CDNs) revalidate with the origin every 10 minutes for fresh content.

Will browsers honour the Expires header despite the existence of a Cache-Control header (which supposedly supersedes it) with a s-maxage directive?

Upvotes: 4

Views: 2711

Answers (2)

Edward Anderson
Edward Anderson

Reputation: 13926

If a response includes both an Expires and a Cache-Control max-age directive, the max-age overrides the Expires header, even if the Expires header is more restrictive. This rule allows an origin server to provide, for a given response, a longer expiration time to an HTTP/1.1 cache than to an HTTP/1.0 cache.

Source: http://condor.depaul.edu/dmumaugh/readings/handouts/SE435/HTTP/node24.html

Upvotes: 2

David Merrilees
David Merrilees

Reputation: 2490

If both are included then both will be checked, neither has precedence. Max-age does not supersede expires, it's additional.

Upvotes: -2

Related Questions