How CORS Preflight Requests Add an Extra Round Trip
A dashboard I was asked to look at last year loaded in 4.2 seconds against an API that answered every call in 30 ms. The Network panel showed 118 requests.

A dashboard I was asked to look at last year loaded in 4.2 seconds against an API that answered every call in 30 ms. The Network panel showed 118 requests. Fifty nine of them were OPTIONS calls that returned no body and did nothing except give permission for the request that followed. The API team had tuned queries for a week. The round trips nobody had counted were costing more than the queries.
Preflight is the part of CORS that developers meet as an error message and then forget about once the error goes away. It is not an error. It is an extra request the browser sends before yours, it costs a full network round trip, and on a mobile connection to a distant region that is 150 to 300 ms per call before your handler sees anything. Knowing exactly which requests trigger it is one of the cheapest performance wins available in a browser, and it is almost entirely a back end configuration problem.
Which requests get a preflight and which do not
The browser splits cross origin requests into two groups. A simple request goes straight out, and the browser decides afterwards whether your JavaScript is allowed to read the response. Anything else gets a preflight first, and your request is never sent at all unless the preflight approves it.
A request stays simple only if all of the following hold. The method is GET, HEAD or POST. The only headers you set are ones on the safelist, which in practice means Accept, Accept-Language, Content-Language and Content-Type. And if you set Content-Type, its value is one of three: application/x-www-form-urlencoded, multipart/form-data or text/plain.
Read that list again with a modern API in mind. Sending JSON means Content-Type: application/json, which is not on the allowed list, so every JSON POST is preflighted. Sending a bearer token means an Authorization header, which is not on the safelist, so every authenticated call is preflighted, including plain reads. PUT, PATCH and DELETE are preflighted by definition. That covers nearly every request a single page app makes, which is why the problem is so widespread and so rarely noticed.
One correction to a belief I keep running into: cookies do not cause a preflight. Sending credentials changes which response headers the server must return, and it blocks the wildcard origin, but a GET with a cookie and no custom headers is still a simple request.
What actually crosses the wire
The preflight is an OPTIONS request to the same URL, carrying two headers that describe what your real request intends to do. The server answers with a set of permissions. Nothing else happens on that round trip.
| Header | Direction | What it says |
|---|---|---|
Origin | Browser to server | Where the page was loaded from |
Access-Control-Request-Method | Browser to server | The method the real request will use |
Access-Control-Request-Headers | Browser to server | Every non safelisted header, lowercased and sorted |
Access-Control-Allow-Origin | Server to browser | One origin, or a wildcard when no credentials are used |
Access-Control-Allow-Methods | Server to browser | Methods permitted on this URL |
Access-Control-Allow-Headers | Server to browser | Headers the client may send |
Access-Control-Max-Age | Server to browser | How long the browser may cache this answer |
You can reproduce the whole exchange without a browser, which is how I check a deploy before trusting it. Point curl at the endpoint with the method set to OPTIONS, add an Origin header matching your front end, add Access-Control-Request-Method: PATCH, and read the response headers. If the status is 204 or 200 and the three allow headers are present, the browser will accept it. If the allow headers are missing you will get the familiar console message, which blames CORS rather than naming the header that was absent.
Two failure modes to recognise on sight. A preflight that returns 401 or 403 means authentication middleware is running before the CORS handler, and the browser never sends credentials on a preflight, so that check can never pass. A preflight that returns 404 means the route is registered for POST only and the framework does not answer OPTIONS on it.
Why the usual Max-Age advice does not work
Search this problem and the answer is always to set Access-Control-Max-Age to something enormous, often 86400 or a year in seconds, and let the browser cache the permission. The header is real and it does help. The advice as written does not, because every browser caps the value and the caps are much lower than people assume.
Chromium clamps the preflight cache to 2 hours, which is 7200 seconds, regardless of what you send. Firefox allows up to 24 hours. Safari has historically sat around 10 minutes. So the year you configured becomes two hours for most of your users, and a tab left open across a working day will preflight again several times. Setting the header is still worth doing, just set 7200 and stop expecting more from it.
There is a second limitation that costs more than the cap. The preflight cache key includes the URL, not just the origin and method. A REST API with per resource paths gets a separate cached preflight for every single resource, so a list view that loads 40 items by id pays 40 preflights on first paint and the cache helps only on repeat visits to the same ids. Chromium has been moving toward a network partitioned cache here, so treat the behaviour as something to measure rather than assume.
The fix that actually removes the cost is to stop the request being cross origin. Serve the API under the same origin as the page, through a path prefix on your existing reverse proxy, and the entire mechanism goes away along with its failure modes. I have done this on four services now and it has never been the exciting answer, which is usually a sign it is the right one. The cost is one proxy block in nginx and the discipline of not bypassing it in client code.
Where a same origin proxy is not possible, the next best moves are ordinary. Drop custom headers you do not need, since every one of them widens Access-Control-Request-Headers and some middleware stacks add headers you never asked for. Collapse chatty endpoints so a view needs three calls rather than forty. And make sure the OPTIONS handler sits in front of auth, logging and rate limiting, because a preflight that queues behind a rate limiter turns a permission check into a 429 and an error your users cannot retry out of.
Measuring it before you change anything
Open the Network panel, filter by OPTIONS, and read the count rather than the timings. That number against your total request count tells you how much of the page load is permission overhead. Anything above about a fifth is worth acting on. Under a tenth, leave it alone and look elsewhere, because a preflight on a fast local network is 5 to 15 ms and you will not feel it.
Then check the real latency rather than your own. A preflight costs one round trip, so its price is whatever your users' round trip time is, and that is 40 ms from the same city and 280 ms from the other side of the world on mobile. The same arithmetic that makes queued requests expensive applies here, and our piece on how browsers limit connections and queue requests covers how those queues interact once you have dozens of extra OPTIONS calls competing for sockets.
Finally, log preflights on the server with their status codes for a week. A surprising share of CORS incidents turn out to be preflights returning 500 from a handler that was never meant to receive them, and that never appears in front end error tracking because the browser reports it as a generic CORS failure. If credentials are part of your setup, the rules on which cookies the browser will even attach are a separate trap, and how browsers decide which cookies to send goes through those. More on the loading pipeline sits in the browsers section.
FAQ
Does a preflight run for every request?
No. Simple requests skip it entirely, and approved preflights are cached for up to the browser cap, keyed by origin, method, headers and URL. In a fresh tab against a JSON API with bearer tokens, expect one preflight per distinct endpoint you touch.
Can I avoid preflight by sending JSON as text/plain?
Technically yes, and I would not. You lose content type correctness, some frameworks stop parsing the body, and you make the endpoint reachable by a cross origin form post, which is exactly the class of request the safelist was drawn around. Fix it at the proxy instead.
Why does my preflight return 401?
Because auth middleware is handling OPTIONS. Browsers deliberately send preflights without credentials, so no token is present. Register the OPTIONS route ahead of authentication, or short circuit it in the first middleware layer.
Is a wildcard in Access-Control-Allow-Origin safe?
For public read only data with no cookies, it is usually fine and simplifies caching. It is not allowed at all once credentials are involved, and in that case you must echo back one specific origin from an allow list, not reflect whatever arrived in the Origin header.
More in Browsers
Browsers
How the Browser Preload Scanner Finds Resources Early
A team I helped last year had a hero image arriving 1.2 seconds into the load on a page whose HTML had finished downloading in...
Browsers
How Browsers Limit Connections and Queue Your Requests
Open the Network panel on a page that loads 40 images and you will see a shape that looks like a staircase.
Browsers
How Web Font Loading Works and How to Avoid Invisible Text
The page has loaded, the layout is there, but the headline and body text are blank for a second or two before they suddenly...