Skip to main content
LowAPI

How to fix: CORS preflight result not cached

Missing Access-Control-Max-Age forces browsers to send preflight OPTIONS on every cross-origin request.

Why it matters

Without preflight caching, every cross-origin API call from browser clients triggers an extra OPTIONS round-trip, doubling perceived latency for API consumers and increasing server load under heavy traffic.

Missing Access-Control-Max-Age forces browsers to send preflight OPTIONS on every cross-origin request.

How to fix it

  1. 1Add Access-Control-Max-Age: 600 (10 minutes) for stable CORS configs
  2. 2Do not set it above 86400 (24 hours); a stale policy can block legitimate requests after a config change

Code examples

Express cors(): set max age

JavaScript
import cors from 'cors';

app.use(cors({
  origin: ['https://app.example.com'],
  methods: ['GET', 'POST', 'PUT', 'DELETE'],
  allowedHeaders: ['Authorization', 'Content-Type'],
  maxAge: 600,
}));

Nginx: CORS preflight with max age

nginx
location /api/ {
    if ($request_method = OPTIONS) {
        add_header Access-Control-Allow-Origin  'https://app.example.com';
        add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE';
        add_header Access-Control-Allow-Headers 'Authorization, Content-Type';
        add_header Access-Control-Max-Age       600;
        return 204;
    }
}

References

Detected automatically by VulnRadar. The check id is api-cors-preflight-cache-missing, stable across every scan so you can filter or diff on it.

See every api check

Questions

How severe is CORS preflight result not cached?
VulnRadar rates this low severity in the api 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 api-cors-preflight-cache-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 cors preflight result not cached

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

How to fix: CORS preflight result not cached | VulnRadar