← Glossary

Vary Header

Definition

The Vary header is an HTTP response header that tells caches, CDNs, and browsers which request headers should be considered when determining whether a cached response can be reused.

Explained

The Vary header is an HTTP response header that tells caches, CDNs, and browsers which request headers should be considered when determining whether a cached response can be reused. It signals that your server provides different content variations based on specific characteristics of the incoming request, such as device type, language preference, or geographic location.

How It Works

The Vary header creates cache keys that include the specified header values. For example:

  • Standard cache key: https://example.com/page
  • With Vary: User-Agent: https://example.com/page + "Mozilla/5.0 (iPhone…)"
  • Multiple variations: https://example.com/page + User-Agent + Accept-Language

This mechanism enables sophisticated content delivery strategies while maintaining optimal caching efficiency, allowing marketing teams to serve highly targeted content variations without sacrificing site speed or SEO performance.

Common Values

  • User-Agent: For device-optimized experiences and mobile conversions
  • Accept-Language: For international market penetration
  • Accept-Encoding: For compression optimization (typically automatic)
  • Authorization: For personalized logged-in experiences

Example

Netflix uses Vary: User-Agent to serve optimized video player interfaces, while Shopify implements Vary: Accept-Language for international market penetration.