Bits and Pieces

Insightful articles, step-by-step tutorials, and the latest news on full-stack composable software development

Follow publication

Member-only story

4 Ways to Reduce CORS Preflight Time in Web Apps

Reducing the negative effect of CORS to improve performance

Chameera Dulanga
Bits and Pieces
Published in
6 min readDec 30, 2020

--

Cross-origin resource sharing (CORS) is an agreement between web browsers and web servers across origins. This agreement allows servers to decide what resources are allowed to access outside it’s hosted domain/sub-domain and instruct the browsers to follow the rules.

For example, you will encounter CORS if your web application is hosted in myapp.com, and it accesses the API in api.myapp.com from the frontend.

Although there is an importance of having CORS for security purposes, most developers overlook its impact on the application performance.

Whenever you make an HTTP request from the frontend to a different domain, the browser will send another HTTP request ahead of that, sequentially to make sure the server grants it.

This additional request is called a Preflight request, and in most cases, it creates a significant delay in response time, affecting the performance of the web application.

--

--

Published in Bits and Pieces

Insightful articles, step-by-step tutorials, and the latest news on full-stack composable software development

Written by Chameera Dulanga

Associate Technical Lead | AWS Community Builder (x4) | Content Manager

Responses (6)

Write a response