If a HTTP response that returns both Expires and max-age indications which one is used?
Cache-Control: max-age=3600 Expires: Tue, 15 May 2008 07:19:00 GMT
Considering that each one refers to a different point in time.
Quick Answer:Expires sets an expiry date for when a cookie gets deleted. Max-age sets the time in seconds for when a cookie will be deleted (use this, it's no longer 2009) Internet Explorer (ie6, ie7, and ie8) does not support “max-age”, while (mostly) all browsers support expires.
If both Expires and max-age are set max-age will take precedence. While Cache-Control and Expires tells the browser when to next retrieve the resource from the network a few additional headers specify how to retrieve the resource from the network. These types of requests are known as conditional requests.
max-age. The max-age directive states the maximum amount of time in seconds that fetched responses are allowed to be used again (from the time when a request is made). For instance, max-age=90 indicates that an asset can be reused (remains in the browser cache) for the next 90 seconds.
Cache-control is an HTTP header used to specify browser caching policies in both client requests and server responses. Policies include how a resource is cached, where it's cached and its maximum age before expiring (i.e., time to live).
See this answer:
Difference between three .htaccess expire rules
If a response includes both an Expires header and a max-age directive, the max-age directive 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 (or later) cache than to an HTTP/1.0 cache. This might be useful if certain HTTP/1.0 caches improperly calculate ages or expiration times, perhaps due to desynchronized clocks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With