Missing Vary: User-Agent: fix dynamic serving
Dynamic serving without a Vary: User-Agent header risks caches showing the wrong version to users and bots. Learn how to fix this cache-poisoning risk.
What it means
Dynamic serving detects the visitor's device and returns different HTML for mobile versus desktop, but the cache key is based only on the URL. Without a Vary: User-Agent header, the cache stores one version and serves it to all requests, so mobile users (and Googlebot) get the desktop HTML—or vice versa.
Why it matters
Googlebot and the mobile indexer only use the mobile version of content, so a cache-poisoned response can serve the wrong markup, headings, or structured data to the crawler. The crawler then indexes stale or mismatched HTML, which can cause indexing gaps or incorrect rendering in Search Console. AI agents that read the same cached HTML will also see the wrong version.
How to fix it
- Add
Vary: User-Agentto the response headers of your dynamic-serving layer so the cache distinguishes mobile and desktop variants. - Verify the header is present on HTML responses using
curl -I https://your-pageand confirm the response includesVary: User-Agent. - If you use a CDN or reverse proxy, configure it to pass the
Varyheader through and purge any existing entries that were cached without it.
Example
<!-- serving different HTML to mobile vs desktop at the same URL -->
Content-Type: text/html
# no Vary headerContent-Type: text/html
Vary: User-AgentIf one URL serves different markup by device (dynamic serving), send Vary: User-Agent so caches and CDNs don't hand the wrong version to a bot or user.
When it's not a problem
This is a false alarm if your server returns identical HTML for both mobile and desktop (content parity), or if you use responsive design with a single HTML template rather than separate mobile/desktop templates.
How Crawlinx detects it
When a URL appears to serve device-specific HTML, we check for a Vary: User-Agent response header. Its absence risks a cache serving the desktop version to mobile (or to Googlebot), so we flag it.
How common is it?
Not yet observed in our audit sample. We publish this explainer because the check runs on every crawl; once an audited site trips it, this page will break the issue down by platform, gatekeeper, vertical and country.
Related guides
Audit your own site — free
157 checks, internal PageRank, render-diff. No signup, results in ~30s.