Skip to main content
InfoConfig

How to fix: Vary Header Missing User-Agent on UA-Dependent Responses

A response appears to vary by User-Agent (e.g., serving different HTML to mobile vs. desktop) but does not include Vary: User-Agent. Caches may serve the wrong variant to the wrong device.

Why it matters

A shared cache may serve a desktop HTML response to a mobile client (or vice versa), causing layout breakage and potentially exposing functionality not intended for that user-agent.

When a server returns different response content based on the User-Agent (adaptive serving for mobile/desktop), it must include Vary: User-Agent so caches store separate copies per user-agent group. Without it, the first visitor's device variant is cached and served to all subsequent visitors.

How to fix it

  1. 1Add Vary: User-Agent to responses that return different HTML or assets based on the user-agent.
  2. 2Prefer client-side responsive design (CSS media queries) to avoid server-side UA detection entirely.
  3. 3If adaptive serving is required, use a CDN with UA grouping/normalization support.

Code examples

Nginx

nginx
# If you serve different content per UA group:
add_header Vary "User-Agent" always;

Prefer responsive CSS over UA detection

CSS
/* Use media queries instead of server-side UA detection */
@media (max-width: 768px) {
  .desktop-only { display: none; }
}

References

Detected automatically by VulnRadar. The check id is vary-header-missing-user-agent, stable across every scan so you can filter or diff on it.

See every config check

Questions

How severe is Vary Header Missing User-Agent on UA-Dependent Responses?
VulnRadar rates this info severity in the config category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id vary-header-missing-user-agent, which stays the same between runs so you can filter, diff, or gate CI on it.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for vary header missing user-agent on ua-dependent responses

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Vary Header Missing User-Agent on UA-Dependent Responses | VulnRadar