The Vary HTTP header is used by servers to indicate that the response can differ based on specific request headers. It tells caches (like browsers, proxy servers, or CDNs) to take certain request headers into account when deciding whether to reuse a cached response for subsequent requests.
Common Use Cases
Content Negotiation: For example, when serving different content based on:
- Accept-Encoding (compressed vs. uncompressed content like gzip or br).
- Accept-Language (language-specific content like en-US or fr-FR).
- User-Agent (different versions for mobile vs. desktop).
Customization: Serving personalized content based on headers like Authorization or Cookie.
Commonly Used Keys in the Vary Header
User-Agent, Accept-Encoding, Cookie,