diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/http/headers/access-control-max-age | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/http/headers/access-control-max-age')
-rw-r--r-- | files/zh-cn/web/http/headers/access-control-max-age/index.html | 78 |
1 files changed, 78 insertions, 0 deletions
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 +--- +<div>{{HTTPSidebar}}</div> + +<p>The <strong><code>Access-Control-Max-Age</code></strong> 这个响应头表示 {{glossary("preflight request")}} (预检请求)的返回结果(即 {{HTTPHeader("Access-Control-Allow-Methods")}} 和{{HTTPHeader("Access-Control-Allow-Headers")}} 提供的信息) 可以被缓存多久。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">报头类型</th> + <td>{{Glossary("Response header")}}</td> + </tr> + <tr> + <th scope="row">{{Glossary("Forbidden header name")}}</th> + <td>no</td> + </tr> + </tbody> +</table> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">Access-Control-Max-Age: <delta-seconds> +</pre> + +<h2 id="指令">指令</h2> + +<dl> + <dt><delta-seconds></dt> + <dd>返回结果可以被缓存的最长时间(秒)。<br> + 在 Firefox 中,<a href="https://dxr.mozilla.org/mozilla-central/rev/7ae377917236b7e6111146aa9fb4c073c0efc7f4/netwerk/protocol/http/nsCORSListenerProxy.cpp#1131">上限是24小时</a> (即 86400 秒)。<br> + 在 Chromium v76 之前, <a href="https://cs.chromium.org/chromium/src/services/network/public/cpp/cors/preflight_result.cc?l=36&rcl=52002151773d8cd9ffc5f557cd7cc880fddcae3e">上限是 10 分钟</a>(即 600 秒)。<br> + 从 Chromium v76 开始,<a href="https://cs.chromium.org/chromium/src/services/network/public/cpp/cors/preflight_result.cc?l=31&rcl=49e7c0b4886cac1f3d09dc046bd528c9c811a0fa">上限是 2 小时</a>(即 7200 秒)。<br> + Chromium 同时规定了一个默认值 5 秒。<br> + 如果值为 <strong>-1</strong>,表示禁用缓存,则每次请求前都需要使用 OPTIONS 预检请求。</dd> +</dl> + +<h2 id="示例">示例</h2> + +<p>将预检请求的结果缓存10分钟:</p> + +<pre>Access-Control-Max-Age: 600 </pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">注释</th> + </tr> + <tr> + <td>{{SpecName('Fetch','#http-access-control-max-age', 'Access-Control-Max-Age')}}</td> + <td>{{Spec2("Fetch")}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("http.headers.Access-Control-Max-Age")}}</p> + +<h2 id="相关内容">相关内容</h2> + +<ul> + <li>{{HTTPHeader("Access-Control-Allow-Headers")}}</li> + <li>{{HTTPHeader("Access-Control-Allow-Methods")}}</li> +</ul> |