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:

  1. Code running in a browser at https://origin-a.com makes a request to https://some-server.com/some/path with the request header Origin: https://origin-a.com.
  2. The https://some-server.com server sends back the response with the content from /some/path and the response header Vary: Origin.
  3. A browser receives the response and caches the content from /some/path.
  4. Code running in the browser at https://origin-b.com makes a request to https://some-server.com/some/path with the request header Origin: https://origin-b.com.
  5. The browser sees that the Origin request-header value for the code from https://origin-b.com is different from that of https://origin-a.com, so instead of using the /some/path content it cached previously, the browser fetches a new response from https://some-server.com/some/path over the network.

For more details, see the following: