aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/http/headers/vary
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/http/headers/vary
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/http/headers/vary')
-rw-r--r--files/zh-cn/web/http/headers/vary/index.html81
1 files changed, 81 insertions, 0 deletions
diff --git a/files/zh-cn/web/http/headers/vary/index.html b/files/zh-cn/web/http/headers/vary/index.html
new file mode 100644
index 0000000000..51f2c1bec6
--- /dev/null
+++ b/files/zh-cn/web/http/headers/vary/index.html
@@ -0,0 +1,81 @@
+---
+title: Vary
+slug: Web/HTTP/Headers/Vary
+translation_of: Web/HTTP/Headers/Vary
+---
+<div>{{HTTPSidebar}}</div>
+
+<p><strong><code>Vary</code></strong> 是一个HTTP响应头部信息,它决定了对于未来的一个请求头,应该用一个缓存的回复(response)还是向源服务器请求一个新的回复。它被服务器用来表明在 <a href="/en-US/docs/Web/HTTP/Content_negotiation">content negotiation</a> algorithm(内容协商算法)中选择一个资源代表的时候应该使用哪些头部信息(headers).</p>
+
+<p>在响应状态码为 {{HTTPStatus("304")}} <code>Not Modified</code>  的响应中,也要设置 Vary 首部,而且要与相应的 {{HTTPStatus("200")}} <code>OK</code> 响应设置得一模一样。</p>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <th scope="row">Header type</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 notranslate">Vary: *
+Vary: &lt;header-name&gt;, &lt;header-name&gt;, ...
+</pre>
+
+<h2 id="说明">说明</h2>
+
+<dl>
+ <dt>*</dt>
+ <dd>所有的请求都被视为唯一并且非缓存的,使用{{HTTPHeader("Cache-Control")}}<code>: no-store</code>,来实现则更适用,这样用于说明不存储该对象更加清晰。</dd>
+ <dt>&lt;header-name&gt;</dt>
+ <dd> 逗号分隔的一系列http头部名称,用于确定缓存是否可用。</dd>
+</dl>
+
+<h2 id="例子">例子</h2>
+
+<h3 id="动态服务">动态服务</h3>
+
+<p><code><font face="Open Sans, arial, sans-serif">哪种情况下使用 </font>Vary: 对于User-Agent</code> 头部信息,例如你提供给移动端的内容是不同的,可用防止你客户端误使用了用于桌面端的缓存。 并可帮助Google和其他搜索引擎来发现你的移动端版本的页面,同时告知他们不需要<a href="https://en.wikipedia.org/wiki/Cloaking">Cloaking</a>。</p>
+
+<pre class="notranslate">Vary: User-Agent</pre>
+
+<h2 id="定义">定义</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">版本</th>
+ <th scope="col">标题</th>
+ </tr>
+ <tr>
+ <td>{{RFC("7231", "Vary", "7.1.4")}}</td>
+ <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</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.Vary")}}</p>
+
+<h2 id="更多关于浏览器兼容性:">更多关于浏览器兼容性:</h2>
+
+<ul>
+ <li><a href="https://blogs.msdn.microsoft.com/ieinternals/2009/06/17/vary-with-care/">Vary with care – Vary header problems in IE6-9</a></li>
+</ul>
+
+<h2 id="更多">更多</h2>
+
+<ul>
+ <li>{{HTTPHeader("Cache-Control")}}</li>
+ <li>{{HTTPHeader("User-Agent")}}</li>
+ <li><a href="https://www.fastly.com/blog/best-practices-for-using-the-vary-header">Best Practices for Using the Vary Header – fastly.com</a></li>
+</ul>