How to fix: Vary: Cookie on Static Resource
A static asset (image, JS, CSS) is served with Vary: Cookie. This forces shared caches to store a separate copy for each unique cookie value, defeating caching entirely for that asset.
Why it matters
All users fetch the same static file on every request without benefiting from CDN or browser caching, causing unnecessary origin load and slow page loads at scale.
Vary: Cookie instructs caches to key stored copies by Cookie header value. For static assets that do not change per user (CSS, JS, images), this is always wrong: it prevents caching and dramatically increases origin bandwidth usage.
How to fix it
- 1Remove Vary: Cookie from static asset responses.
- 2Configure the CDN or web server to strip Vary: Cookie for assets at /static/, /_next/static/, /public/ paths.
Code examples
Nginx: static asset cache config
location ~* \.(js|css|png|jpg|webp|woff2|ico)$ {
expires 1y;
add_header Cache-Control "public, immutable";
# No Vary: Cookie here
}References
Detected automatically by VulnRadar. The check id is vary-cookie-on-static-resource, 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
- MediumCORS Endpoint Missing Vary: Origin
Questions
- How severe is Vary: Cookie on Static Resource?
- 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-cookie-on-static-resource, 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.