diff options
author | shenyang <772413326@qq.com> | 2021-06-24 20:50:19 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2021-06-25 15:23:21 +0800 |
commit | 587281ee45ceb6758792d76e8264e0ea8c4e26ba (patch) | |
tree | 669ae9338448953202dcd9cc9db3079bcb352c78 /files/zh-cn/web/http | |
parent | b15ca69bf6b10ab3e42585baca640171c9e18792 (diff) | |
download | translated-content-587281ee45ceb6758792d76e8264e0ea8c4e26ba.tar.gz translated-content-587281ee45ceb6758792d76e8264e0ea8c4e26ba.tar.bz2 translated-content-587281ee45ceb6758792d76e8264e0ea8c4e26ba.zip |
fix(cache-control): 页面内容和其他页面保持一致
Diffstat (limited to 'files/zh-cn/web/http')
-rw-r--r-- | files/zh-cn/web/http/headers/cache-control/index.html | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/files/zh-cn/web/http/headers/cache-control/index.html b/files/zh-cn/web/http/headers/cache-control/index.html index 00d8e82160..b431fc74d7 100644 --- a/files/zh-cn/web/http/headers/cache-control/index.html +++ b/files/zh-cn/web/http/headers/cache-control/index.html @@ -30,7 +30,13 @@ translation_of: Web/HTTP/Headers/Cache-Control <h2 id="语法">语法</h2> -<p>指令不区分大小写,并且具有可选参数,可以用令牌或者带引号的字符串语法。多个指令以逗号分隔。</p> +<p>指令格式如下:</p> + +<ul> + <li>不区分大小写,但建议使用小写。</li> + <li>多个指令以逗号分隔。</li> + <li>具有可选参数,可以用令牌或者带引号的字符串语法。</li> +</ul> <h3 id="缓存请求指令">缓存请求指令</h3> @@ -138,30 +144,41 @@ Cache-control: stale-if-error=<seconds> <h3 id="需要重新验证">需要重新验证</h3> -<p>指定 <code>no-cache</code> 或 <code>max-age=0</code> 表示客户端可以缓存资源,每次使用缓存资源前都必须重新验证其有效性。这意味着每次都会发起 HTTP 请求,但当缓存内容仍有效时可以跳过 HTTP 响应体的下载。</p> +<p>指定 <code>no-cache</code> 或 <code>max-age=0, must-revalidate</code> 表示客户端可以缓存资源,每次使用缓存资源前都必须重新验证其有效性。这意味着每次都会发起 HTTP 请求,但当缓存内容仍有效时可以跳过 HTTP 响应体的下载。</p> + +<pre class="brush: http">Cache-Control: no-cache</pre> -<pre>Cache-Control: no-cache -Cache-Control: max-age=0</pre> +<pre class="brush: http">Cache-Control: max-age=0, must-revalidate</pre> + +<p><strong>注意</strong>: 如果服务器关闭或失去连接,下面的指令可能会造成使用缓存。</p> + +<pre class="brush: http">Cache-Control: max-age=0</pre> <h2 id="规范">规范</h2> <table class="standard-table"> - <tbody> + <thead> <tr> <th scope="col">Specification</th> - <th scope="col">Title</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> </tr> + </thead> + <tbody> <tr> - <td>{{RFC("7234")}}</td> - <td>Hypertext Transfer Protocol (HTTP/1.1): Caching</td> + <td>{{RFC(8246, "HTTP Immutable Responses")}}</td> + <td><span class="spec-RFC">IETF RFC</span></td> + <td></td> </tr> <tr> - <td>{{RFC("5861")}}</td> - <td>HTTP Cache-Control Extensions for Stale Content</td> + <td>{{RFC(7234, "Hypertext Transfer Protocol (HTTP/1.1): Caching")}}</td> + <td><span class="spec-RFC">IETF RFC</span></td> + <td></td> </tr> <tr> - <td><a href="https://tools.ietf.org/html/draft-mcmanus-immutable-00">draft-mcmanus-immutable-00</a></td> - <td>HTTP Immutable Responses</td> + <td>{{RFC(5861, "HTTP Cache-Control Extensions for Stale Content")}}</td> + <td><span class="spec-RFC">IETF RFC</span></td> + <td>Initial definition</td> </tr> </tbody> </table> @@ -173,9 +190,9 @@ Cache-Control: max-age=0</pre> <h2 id="参见">参见</h2> <ul> - <li><a href="https://wiki.developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ">HTTP Caching FAQ</a></li> + <li><a href="/zh-CN/docs/Web/HTTP/Caching">HTTP Caching FAQ</a></li> <li><a href="https://www.mnot.net/cache_docs/">Caching Tutorial for Web Authors and Webmasters</a></li> - <li>Guide: <em><a href="https://csswizardry.com/2019/03/cache-control-for-civilians"><code>Cache-Control</code> for civilians</a></em></li> + <li>Guide: <em><a href="https://csswizardry.com/2019/03/cache-control-for-civilians"><code>Cache-Control</code> for civilians</a></em></li> <li>{{HTTPHeader("Age")}}</li> <li>{{HTTPHeader("Expires")}}</li> <li>{{HTTPHeader("Pragma")}}</li> |