browser-cachecache-controllast-modifieds-maxage

Is max age relative to last-modified date or request time?


When a server gives Cache-Control: max-age=4320000,

Is the freshness considered 4320000 seconds after the time of request, or after the last modified date?


Solution

  • RFC 2616 section 14.9.3:

    When the max-age cache-control directive is present in a cached response, the response is stale if its current age is greater than the age value given (in seconds) at the time of a new request for that resource. The max-age directive on a response implies that the response is cacheable (i.e., "public") unless some other, more restrictive cache directive is also present.

    It is always based on the time of request, not the last modified date. You can confirm this behavior by testing on the major browsers.