Is Cache-Control: necessary-revalidate to oblige to check all requests or just outdated?

I have a mess with this header, I read that Cache-Control:must-revalidate requires checking all requests with the source before serving the cached item, but only outdated ones? or all regardless of whether they are outdated or fresh? I read both things in different places.

What is the difference with Cache-Control:no-cache ? Because these headlines are like me.

UPDATE 1: I read this from the book:

Cache-Control: must-revalidate specifies a cache to bypass mechanisms for calculating freshness and checking for every access

@Peter O. indicated what the RFC says. So the old book is wrong.

UPDATE 2: In this lesson: http://www.mnot.net/cache_docs/

no-cache - forces caches to send a request to the source server for confirmation before releasing a cached copy each time. This is useful to ensure that authentication is respected (in conjunction with the public) or to maintain strong freshness without sacrificing the benefits of caching.

must-revalidate - indicates the cache that they must obey any freshness information you give them about the presentation. HTTP allows caches to serve deprecated views under special conditions; By specifying this heading, you tell the cache that you want it to strictly abide by your rules.

+6
source share
1 answer

Section 14.9.4 HTTP / 1.1:

If the must-revalidate directive is present in the response of the received cache, this cache MUST NOT use the record after it becomes stale to answer a subsequent request without first checking it again from the server of origin

Section 14.8 of the HTTP / 1.1 Protocol:

If the response includes cache control of the "must-revalidate" directive, the cache MAY use this response in response to a subsequent request. But if the answer is out of date, all caches MUST first check it with the origin server ...

So it seems that only outdated answers should be checked if must-revalidate .

For no-cache , see section 14.9.1:

If the no-cache directive does not specify a field name [which is the case here], then the cache MUST NOT use the response to satisfy a subsequent request without successfully re-checking with the origin server ...

Thus, no-cache applies to both new and obsolete answers.

EDIT:

This phrase may have a meaning here (section 13.3):

When a cache has an outdated record that he would like to use as a response to a client request, you first need to check with the source server (or, possibly, an intermediate cache with a new response) to find out if its cached record is still available.

So, must-revalidate probably matters when the cache has an intermediate cache, because otherwise the cache can check the intermediate cache for and not check the source server directly.

+10
source

Source: https://habr.com/ru/post/898162/


All Articles