Описание тега vary
The Vary response header is used for indicating to browsers and other user agents which request header values to check when deciding whether to load content from a cache or to instead fetch a new response over the network.
The Vary
header is defined in RFC 7231 http://httpwg.org/specs/rfc7231.html. Its value is a list of header names. Here’s a simple example of how it works:
- Code running in a browser at
https://origin-a.com
makes a request tohttps://some-server.com/some/path
with the request headerOrigin: https://origin-a.com
. - The
https://some-server.com
server sends back the response with the content from/some/path
and the response headerVary: Origin
. - A browser receives the response and caches the content from
/some/path
. - Code running in the browser at
https://origin-b.com
makes a request tohttps://some-server.com/some/path
with the request headerOrigin: https://origin-b.com
. - The browser sees that the
Origin
request-header value for the code fromhttps://origin-b.com
is different from that ofhttps://origin-a.com
, so instead of using the/some/path
content it cached previously, the browser fetches a new response fromhttps://some-server.com/some/path
over the network.
For more details, see the following: