1

I just checked the cache-control header returned by webmasters.stackexchange.com. The only directive present in the response is cache-control: private. In this case, what are the default values for other directives including max-age? Should a client re-validate (checking if the content is modified on the server) for every request?

1 Answer 1

1

Mozilla has a HTTP Caching FAQ that says:

[In this case] then the expiration calculation is essentially the algorithm described in RFC 2616 section 13.2.

...

The expiration time is computed as follows:

expirationTime = responseTime + freshnessLifetime - currentAge

where responseTime is the time at which the response was received according to the browser.

...

The freshness lifetime is calculated based on several headers. ... If [neither max-agenor Expires header are] present, then we look for a Last-Modified header. If this header is present, then the cache's freshness lifetime is equal to the value of the Date header minus the value of the Last-modified header divided by 10.

When I investigated this heuristic of Last-modified / 10 for Why is this response being cached?, I found that all major browsers appear to use this same heuristic.

According to Cache-Control - HTTP | MDN, clients must only revalidate if one of the following headers is present:

  • no-cache
  • max-age=0, must-revalidate

Since neither of those headers are present in this case, no revalidation needs to occur.

2
  • Sorry if I am missing something. But what if last-modified header isn't present? I couldn't find one in the response of webmasters.stackexchange.com. In such cases, do browsers use some default value?
    – Kannan
    Jun 1, 2021 at 11:11
  • 1
    Most pages on this site have Last-modified: curl --head https://webmasters.stackexchange.com/questions/134583/default-cache-control-directives-and-behaviour-when-header-returns-only-privat/134589 shows last-modified: Tue, 01 Jun 2021 11:11:17 GMT. It appears that the home page does not and I'm not sure what browsers assume in that case. I'd assume they have to use "modified just now" as the default because there is no other sane assumption. Jun 1, 2021 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.