Deutsch

The Vary header is an HTTP response header that lists which request headers influenced the response, so that caches store and serve each variant separately.

How does the Vary header work?

Per MDN, Vary describes the parts of a request, apart from method and URL, that shaped the response. A cache then stores one copy per combination of the listed header values. Vary: * means that factors beyond request headers played a role, which makes the response uncacheable. MDN also says the same Vary value should be sent on all responses for a URL, including 304 responses.

Typical values are Accept-Encoding (compressed and uncompressed copies), Accept-Language and User-Agent.

For SEO, Google’s mobile-first indexing documentation names Vary: user-agent as part of dynamic serving, where the same URL returns different HTML to different devices. The header tells caches that the response depends on the user agent. Responsive pages with one HTML for all devices do not need it.

Mobile site configurations compared
ConfigurationURLHTMLTechnical signalsGoogle's position
Responsive designsame URL on every devicesame HTML; the layout adapts to the screen sizenone needed; content and metadata are identical on mobile and desktoprecommended as the easiest pattern to implement and maintain
Dynamic servingsame URL on every devicedifferent HTML per device, chosen by user-agent detectionVary: user-agent response headersupported; the mobile version needs the same content as desktop
Separate mobile URLsa separate URL per device, e.g. m.example.comdifferent HTML per devicemobile page: rel="canonical" to the desktop URL; desktop page: rel="alternate" with media to the mobile URL; redirects based on user agent and Varysupported; the desktop URL is always canonical, and hreflang links mobile to mobile and desktop to desktop

Google uses the mobile version of a page, crawled with the smartphone agent, for indexing and ranking (mobile-first indexing). Only the content shown on the mobile version is used for indexing. Google's best practices on signals and content parity apply to dynamic serving and separate URLs only; with responsive design, content and metadata are the same anyway. Sources: Google Search Central: Mobile site and mobile-first indexing best practices (last updated 2025-12-10); MDN: Vary header. Last checked: .

Example

HTTP
HTTP/1.1 200 OK
Vary: Accept-Encoding, User-Agent

Common mistakes

Vary: User-Agent is set on pages that return identical HTML, which splits the cache into many copies without benefit.

Sources

  1. Vary header – MDNdeveloper.mozilla.org
  2. RFC 9110: Varyrfc-editor.org
  3. Mobile-first indexing best practices – Google Search Centraldevelopers.google.com

Last updated: