How to fix: Vary Header Missing on Compressed Responses
A compressed response (Content-Encoding: gzip/br) is missing the Vary: Accept-Encoding header. Without it, a shared cache can serve a compressed response to a client that does not support compression. A response marked Cache-Control: no-store, no-cache or private is not reported, since no shared cache may store it in the first place.
Why it matters
A caching intermediary that stores the compressed response without Vary: Accept-Encoding may serve garbled content to clients that do not support gzip/brotli, causing pages to display as binary garbage or fail to render entirely.
When a server returns content-encoded responses (gzip, brotli), it must include Vary: Accept-Encoding. This tells caches to store separate copies per Accept-Encoding value and serve the right one to each client. Without this, compressed responses can be served to clients that declared they cannot decompress them.
How to fix it
- 1Add Vary: Accept-Encoding to every response that uses Content-Encoding: gzip or br.
- 2Most frameworks (Express, nginx with gzip_vary on) handle this automatically.
Code examples
Nginx
gzip on;
gzip_vary on; # automatically adds Vary: Accept-EncodingNext.js (via headers config)
// Next.js adds Vary: Accept-Encoding automatically for compressed responses.
// Verify it is present:
// curl -I -H 'Accept-Encoding: gzip' https://example.com/References
Detected automatically by VulnRadar. The check id is vary-header-missing, 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
- InfoDownloadable Content Served as inline
- InfoX-XSS-Protection Header Is Deprecated
- LowServer-Timing Exposes Cache Timings
- LowVary: Cookie on Static Resource
- MediumCORS Endpoint Missing Vary: Origin
Questions
- How severe is Vary Header Missing on Compressed Responses?
- VulnRadar rates this low 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, 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.