CORS访问控制 - 最大年龄被忽略 [英] CORS Access-Control-Max-Age is ignored
问题描述
我在不同的域托管一个WebApp和他的API,并使用CORS能够工作在同一起源政策。到现在为止还挺好。这工作。
为了只发送一个CORS预检每个会话我设置
访问控制最大年龄20天,但这不工作(在Chrome中测试):
https://db.tt/vfIW3fD2
$ b $ Chrome / Blink的最大预检时间为10分钟(600秒) )。以下是源代码中定义此位置的位置:
超过10分钟的任何预检时间将被忽略,而将使用10分钟。
不同的浏览器可能有不同的最高年龄政策。 Safari / WebKit缓存长达5分钟,而Firefox缓存长达24小时。 Chrome源代码表示存在最大值,以最小化切换到安全网络后使用中毒缓存的风险。
EDIT :另请注意,代码定义的默认超时为5秒:
如果代码无法解析max-年龄头(或服务器未指定max-age头),浏览器默认为5秒。
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?
Chrome/Blink imposes a max preflight time of 10 minutes (600 seconds). Here's the location in source code that defines this:
Any preflight time above 10 minutes will be ignored, and 10 minutes will be used instead.
Different browsers may have different max age policies. Safari/WebKit caches for up to 5 minutes, while Firefox caches for up to 24 hours. The Chrome source code indicates that the max value exists in order to "minimize the risk of using a poisoned cache after switching to a secure network".
EDIT: Also note that the code defines a default timeout of 5 seconds:
If the code can't parse the max-age header (or the server doesn't specify a max-age header), the browser defaults to 5 seconds.
这篇关于CORS访问控制 - 最大年龄被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!