elements icon indicating copy to clipboard operation
elements copied to clipboard

CORS preflight calls are slowing down pages

Open rpascalsdl opened this issue 4 years ago • 1 comments

User story.

When using 'elements-dev'portal", besides the high response times (over 200ms measured at 2 location) for all requests, there is an additional request for CORS preflight. The CORS preflight request was measured at 185-215ms (at 2 locations). That adds up to at least over 400ms to get any data from the Stoplight servers. Ex: image

Is that by design? I don't know. Can you get rid of those CORS preflight requests? yes. The reason they are generated by the browser is explained here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#preflighted_requests

I did make a local copy of web-components.min.js, and removed the stoplight-elements-version from the request. The result is no more CORS preflight requests, and I shaved 200ms off, as you can see in the screenshot:

image

Is your feature request related to a problem?

Yes. Pages load visibly too long. Clicking on any endpoint contract, takes painfully long to render. This is a quick win to get those response times lower.

Describe the solution you'd like

The solution is up to you, but if you really need that stoplight-elements-version header in the request, you could put it as query parameter in the url.

rpascalsdl avatar Dec 24 '21 14:12 rpascalsdl

Hey team! Please add your planning poker estimate with ZenHub @mallachari @mmiask @mpodlasin @Nezteb @paulatulis @wmhilton @domagojk

mnaumanali94 avatar Jan 11 '22 15:01 mnaumanali94