codefx
codefx

Reputation: 10512

Is it possible to cache HTTP OPTIONS response?

I am making CORS calls. Now, every api call has a OPTIONS preflight call. Is it possible to cache the OPTIONS preflight call?

I see that Cache-Control header can be used to cache actual GET response. https://www.fastly.com/blog/caching-cors

But how do I cache the response of the OPTIONS call?

Upvotes: 10

Views: 7225

Answers (2)

Alireza Rahmani Khalili
Alireza Rahmani Khalili

Reputation: 2954

According to this:

Responses to this method are not cacheable.

Upvotes: 0

Carlos Saltos
Carlos Saltos

Reputation: 1511

Caching HTTP OPTIONS for CORS preflight requests is a sensible thing.

If the response body is exactly the same for all the CORS preflight requests for any browser version, origin or client, then you may activate HTTP OPTIONS caching.

If unsure, leave the HTTP OPTIONS without caching to prevent breaking HTTP CORS based requests ... after all the HTTP OPTION requests are very light and quick compared with the actual HTTP flight request (and on top of that, the browsers made already a client side cache for the HTTP OPTIONS preflight requests for CORS).

Upvotes: 0

Related Questions