Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CORS Access-Control-Max-Age is ignored

I'm hosting an WebApp and his API on different domains and use CORS to be able to work around the same origin policy. So far, so good. This works.

To only send a CORS preflight once per session I set the Access-Control-Max-Age to 20 days, But this is not working (tested in Chrome): https://db.tt/vfIW3fD2

What do I have to change?

like image 350
Roland Schütz Avatar asked May 08 '14 13:05

Roland Schütz


People also ask

How long is Max-age 31536000?

It is advisable to assign the max-age directive's value to be greater than 10368000 seconds (120 days) and ideally to 31536000 (one year).

What is Maxage in CORS?

Access-Control-Max-Age is used in CORS preflight requests. It indicates how long the results of a preflight request can be cached. The results in this case is the content of the Access-Control-Allow-Methods and Access-Control-Allow-Headers headers.

What is Max-age in HTTP header?

max-age. The max-age directive states the maximum amount of time in seconds that fetched responses are allowed to be used again (from the time when a request is made). For instance, max-age=90 indicates that an asset can be reused (remains in the browser cache) for the next 90 seconds.


1 Answers

If you are using Chrome Dev Tools, make sure you have "Disable cache (while DevTools is open)" unchecked. I was having issues with the "Access-Control-Max-Age" not being honored only to realize that I had that option checked.

like image 101
Nej Kutcharian Avatar answered Oct 13 '22 00:10

Nej Kutcharian