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
- 1Add Vary: User-Agent to responses that return different HTML or assets based on the user-agent.
- 2Prefer client-side responsive design (CSS media queries) to avoid server-side UA detection entirely.
- 3If adaptive serving is required, use a CDN with UA grouping/normalization support.
Code examples
Nginx
# If you serve different content per UA group:
add_header Vary "User-Agent" always;Prefer responsive CSS over UA detection
/* 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.
More config checks
- MediumNo Rate-Limit Policy Detected
- MediumVary: Cookie Missing on Cookie-Bearing Response
- LowSet-Cookie Header Exceeds 4 KB
- LowVary Header Missing on Compressed Responses
- InfoDownloadable Content Served as inline
- InfoX-XSS-Protection Header Is Deprecated
- LowServer-Timing Exposes Cache Timings
- LowVary: Cookie on Static Resource
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.