Vary

The HTTP Vary header lists the other HTTP headers that were used to create the current representation.

Table of Contents

Usage

The HTTP Vary header is used to keep track of other HTTP headers that were relied upon to generate the current representation. For example, consider a resource that is available in HTML format by default. In this case, the client requests the resource in text/plain instead of text/html. This is done using the HTTP Accept header, as follows:

Accept: text/plain

Because the HTTP Accept header causes a non-default representation of the resource to be generated, the HTTP Accept header is relevant to its recreation and is therefore included in HTTP Vary, as follows:

Vary: Accept

This is important because shared caches have to understand what HTTP headers, encodings, and other operations have been applied to the resource.

Takeaway

The HTTP Vary header is used to keep track of the headers that were relevant in the generation of the response.

See also

Last updated: June 2, 2022