# Vary header

> Lists the request headers a response depends on, controlling cache key selection.

Source: https://apiguide.dev/headers/vary
Direction: response
Registered: yes
Defined in: RFC 9110, Section 12.5.5 <https://www.rfc-editor.org/rfc/rfc9110.html#section-12.5.5>
Updated: 2026-07-10

## What is the Vary header?

The `Vary` response header, defined in RFC 9110, names the request headers that a cache must consider before serving a stored response. It tells caches that the same URL can produce different representations depending on those headers.

## API Usage & Best Practices

* **Correct content negotiation**: Listing `Accept`, `Accept-Encoding`, or `Accept-Language` ensures a client asking for JSON is never served a cached HTML response, and a gzip-capable client is not handed a brotli body it cannot read.
* **Protect private data**: Including `Authorization` prevents a shared cache from returning one user's personalized response to another.
* **Use the wildcard sparingly**: `Vary: *` means the response varies on factors outside the request headers, which effectively makes it uncacheable by shared caches.

## Examples

```http
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Accept, Accept-Encoding
```
