From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../http/headers/access-control-max-age/index.html | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 files/zh-cn/web/http/headers/access-control-max-age/index.html (limited to 'files/zh-cn/web/http/headers/access-control-max-age') diff --git a/files/zh-cn/web/http/headers/access-control-max-age/index.html b/files/zh-cn/web/http/headers/access-control-max-age/index.html new file mode 100644 index 0000000000..46ccab97ce --- /dev/null +++ b/files/zh-cn/web/http/headers/access-control-max-age/index.html @@ -0,0 +1,78 @@ +--- +title: Access-Control-Max-Age +slug: Web/HTTP/Headers/Access-Control-Max-Age +tags: + - 超文本传输协议 + - 跨域资源请求 + - 首部 +translation_of: Web/HTTP/Headers/Access-Control-Max-Age +--- +
{{HTTPSidebar}}
+ +

The Access-Control-Max-Age 这个响应头表示 {{glossary("preflight request")}}  (预检请求)的返回结果(即 {{HTTPHeader("Access-Control-Allow-Methods")}} 和{{HTTPHeader("Access-Control-Allow-Headers")}} 提供的信息) 可以被缓存多久。

+ + + + + + + + + + + + +
报头类型{{Glossary("Response header")}}
{{Glossary("Forbidden header name")}}no
+ +

语法

+ +
Access-Control-Max-Age: <delta-seconds>
+
+ +

指令

+ +
+
<delta-seconds>
+
返回结果可以被缓存的最长时间(秒)。
+ 在 Firefox 中,上限是24小时 (即 86400 秒)。
+ 在 Chromium v76 之前, 上限是 10 分钟(即 600 秒)。
+ 从 Chromium v76 开始,上限是 2 小时(即 7200 秒)。
+ Chromium 同时规定了一个默认值 5 秒。
+ 如果值为 -1,表示禁用缓存,则每次请求前都需要使用 OPTIONS 预检请求。
+
+ +

示例

+ +

将预检请求的结果缓存10分钟:

+ +
Access-Control-Max-Age: 600 
+ +

规范

+ + + + + + + + + + + + + + +
规范状态注释
{{SpecName('Fetch','#http-access-control-max-age', 'Access-Control-Max-Age')}}{{Spec2("Fetch")}}Initial definition.
+ +

浏览器兼容性

+ + + +

{{Compat("http.headers.Access-Control-Max-Age")}}

+ +

相关内容

+ + -- cgit v1.2.3-54-g00ecf