Is there ever any reason to respond with "Vary: *" and "Vary: Foo" for the same resource?
Is there any reason for a HTTP server to sometimes respond with Vary: *
, and sometimes with Vary: Foo
, to requests for the same resource?
What shoul开发者_C百科d a cache do, if after receiving (and caching) both responses, it then receives a request with a matching Foo
header, for which the Vary: Foo
response is suitable? Can it serve the matching response, or does the separate Vary: *
response override it?
Each response is evaluated in isolation, so it can select the Vary: Foo response.
See:
- https://svn.tools.ietf.org/svn/wg/httpbis/draft-ietf-httpbis/latest/p6-cache.html#constructing.responses.from.caches
- https://svn.tools.ietf.org/svn/wg/httpbis/draft-ietf-httpbis/latest/p6-cache.html#caching.negotiated.responses
There may be a situation where a server can guarantee that for a certain time a resource's representation is only influenced by Foo
but after some time have elapsed, it can no longer make any guarantee and must set the header to Vary: *
.
Expiration is preferred over validation. Since Vary: *
forces revalidation, the cache should select the Foo
response assuming it is fresh.
精彩评论