Browser & Web Performance · Senior · Question 43 of 75
Why do preflights hurt performance in an API-heavy SPA, and how can you reduce them?
- ✓Correct answer: Each non-simple cross-origin request may need an extra
OPTIONSround trip; use the same origin (e.g. a proxy path) or a longAccess-Control-Max-Age - 2Preflights block rendering; load them with
defer - 3Preflights download the API schema; disable it in
fetchoptions
Explanation
Serving the API under the app's origin (/api) removes CORS entirely. Preflight caching is per URL and capped by browsers.