Skip to main content

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

  1. 1Add Vary: Accept-Encoding to every response that uses Content-Encoding: gzip or br.
  2. 2Most frameworks (Express, nginx with gzip_vary on) handle this automatically.

Code examples

Nginx

nginx
gzip on;
gzip_vary on;  # automatically adds Vary: Accept-Encoding

Next.js (via headers config)

JavaScript
// 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.

See every config check

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.

Propose a checkHow a check is built

Scan your own site for vary header missing on compressed 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 on Compressed Responses fix | VulnRadar