HTTP 标头字段“Content-Location"的用途是什么? [英] What is the purpose of the HTTP header field “Content-Location”?
问题描述
对我的问题的评论感到困惑/启发 搜索引擎是否尊重 HTTP 标头字段Content-Location"?,我想知道 Content-Location
HTTP 中的标头字段 是以及如何使用它.
Confused/inspired by a comment to my question Do search engines respect the HTTP header field "Content-Location"?, I’d like to know, what the exact purpose of the Content-Location
header field in HTTP is and how it can be used.
推荐答案
响应 GET 请求,HTTP 中的 Content-Location 可以在请求的资源有多个可用表示时使用,例如多种语言.返回的资源的选择将取决于原始 GET 请求中的 Accept 标头.
In response to a GET request, Content-Location in HTTP can be used when a requested resource has multiple representations available, e.g. multiple languages. The selection of the resource returned will depend on the Accept headers in the original GET request.
通常,Content-Location 标头中指定的位置与原始请求的 URI 中指定的位置不同.
Usually, the location specified in the Content-Location header is different to the location specified in the original request's URI.
响应 PUT 或 POST 请求,
In response to a PUT or POST request,
- 如果 Content-Location URI 与请求的 URI 不同,则指定 URI 处的缓存条目无效.(见 https://www.rfc-editor.org/rfc/rfc7234#第 4.4 节 和 https://www.rfc-editor.org/rfc/rfc2616#section-13.10)
- 如果 Content-Location URI 与请求的 URI 相同,则表明缓存对 PUT/POST 请求的响应与对 GET 请求的 200 响应将收到的响应相同相同的位置,因此可以被缓存.(见 https://www.rfc-editor.org/rfc/rfc7231#section-3.1.4.2) 请注意,Firefox 和 Chrome 似乎没有实现这一点.
- If the Content-Location URI is different than the requested URI, then the cache entry at the indicated URI is invalidated. (see https://www.rfc-editor.org/rfc/rfc7234#section-4.4 and https://www.rfc-editor.org/rfc/rfc2616#section-13.10)
- If the Content-Location URI is the same as the requested URI, then that indicates to caches that the response to the PUT/POST request is the same as the response that would be received by a 200 response to a GET request at the same location and can thus be cached. (see https://www.rfc-editor.org/rfc/rfc7231#section-3.1.4.2) Note that Firefox and Chrome do not appear to implement this.
这篇关于HTTP 标头字段“Content-Location"的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!