Server and HTTP · Server behaviour
Missing Vary header with dynamic serving
This page sends different HTML to mobile and desktop browsers at one URL, but has no Vary: User-Agent header to warn caches.
How this page is built
A Netlify Edge Function on this page checks the user agent. Mobile browsers get HTML with a mobile class on the body element, and desktop browsers get it without. The words on the page are the same for both, so only the markup changes.
Neither response has a Vary: User-Agent header. To compare them, request the page with curl, once with a mobile user agent and once with a desktop one.
Why it matters
Dynamic serving sends different HTML to different devices from the same URL. The Vary: User-Agent header tells caches and CDNs that the response depends on the user agent, so they keep a separate copy for each.
Without it, a cache can store the desktop page and serve it to phones, or the other way round. Google also uses the header as a hint that the page has a mobile version to crawl.
How to check it
Request the page with a desktop and a mobile user agent and compare the HTML. If it differs, check the response headers for Vary: User-Agent. Header checkers and the network panel in your browser’s developer tools show the Vary header.
How to fix it
Add Vary: User-Agent to every response whose HTML changes with the user agent. Better still, move to a responsive design that serves the same HTML to every device and adapts with CSS, which Google recommends.
Then check the header on both mobile and desktop responses.