What is the purpose of the HTTP header field “Content-Location”?

后端 未结 4 478
终归单人心
终归单人心 2020-12-08 04:33

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-Lo

4条回答
  •  囚心锁ツ
    2020-12-08 04:54

    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.

    Usually, the location specified in the Content-Location header is different to the location specified in the original request's URI.

    In response to a PUT or POST request,

    • If the Content-Location URI is different than the requested URI, then the cache entry at the indicated URI is invalidated. (see https://tools.ietf.org/html/rfc7234#section-4.4 and https://tools.ietf.org/html/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://tools.ietf.org/html/rfc7231#section-3.1.4.2) Note that Firefox and Chrome do not appear to implement this.

提交回复
热议问题