Fetch: Access-Control-Max-Age is never honoured

Created on 5 Jun 2016  路  1Comment  路  Source: github/fetch

I have a fetch with CORS, with some custom HTTP headers. Due to that, preflight OPTION fetch is required before the actual fetch.

In the return of that preflight, I have set the Access-Control-Max-Age (https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS). However, in the subsequence fetch, preflight OPTION fetch are still happening. In fact, no fetch happens without preflight.

I have checked the answers from http://stackoverflow.com/questions/23543719/cors-access-control-max-age-is-ignored, seems not related to my case.

Is it possible that within fetch module itself, the preflight fetch is always invoked regardless the Access-Control-Max-Age?

Most helpful comment

Solved. It turns out preflight cache is per URL, not per domain 馃槥 .

"In order to reduce the number of preflight requests, CORS has the concept of a preflight cache. However the preflight information is cached for an origin/url pair. That means each unique url has its own preflight cache. An API with the same preflight response across all urls will still receive a preflight request for each unique request."

http://monsur.hossa.in/2012/09/07/thoughts-on-the-cors-preflight-cache.html

>All comments

Solved. It turns out preflight cache is per URL, not per domain 馃槥 .

"In order to reduce the number of preflight requests, CORS has the concept of a preflight cache. However the preflight information is cached for an origin/url pair. That means each unique url has its own preflight cache. An API with the same preflight response across all urls will still receive a preflight request for each unique request."

http://monsur.hossa.in/2012/09/07/thoughts-on-the-cors-preflight-cache.html

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mmocny picture mmocny  路  3Comments

codeashian picture codeashian  路  3Comments

karladler picture karladler  路  4Comments

sndsgn picture sndsgn  路  3Comments

proofrock picture proofrock  路  3Comments