Skip to main content

4.9.4. Varying Content Based Upon the Request

4.9.4. Varying Content Based Upon the Request

When a resource's representation can vary based on aspects of the request (such as the Accept header field for content negotiation), the Vary header field MUST be used to indicate which request header fields affect the selected representation.

For example:

Vary: Accept, Accept-Language

indicates that the representation might vary based on the Accept and Accept-Language header fields.

Applications that use content negotiation or other request-based variation MUST use the Vary header field appropriately. This ensures that caches can correctly store and retrieve different representations.

However, applications SHOULD be aware that using Vary can significantly reduce cache efficiency, as caches need to store separate copies of the response for each combination of varying header field values.