HTTP标头的含义是什么变化:* [英] What is the meaning of the HTTP header Vary:*

查看:177
本文介绍了HTTP标头的含义是什么变化:*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,HTTP标头 Vary 指定了一个逗号分隔的HTTP标头列表,在决定是否有请求时需要由缓存和URL一起考虑是缓存命中或未命中。



如果省略该标题,则表示只考虑URL。



<但是当标题是时会发生什么变化:*



RFC 2616 14.4


***的变化字段值表示未指定的参数不是
限于请求-headers(例如,
客户端的网络地址)在响应表示的选择中起作用。
*值绝不能由代理服务器生成;它可能只是原始服务器生成的


RFC 2616 13.6


*的Vary标头字段值始终无法匹配,该资源上的后续
请求只能由
源服务器正确解释。


这是否意味着具有此标头的所有请求都将成为缓存未命中?



如果你使用他们的 OutputCacheAttribute ,我发现ASP.NET正在返回那个HTTP头,你必须如果你不想要标题,或者你想指定自定义标题,那么显式禁用该行为,所以我(想)相信它不太可能。



这是什么的实际含义不同:*



谢谢。

解决方案

Vary:*告诉缓存已根据HTTP内容协商的常规方面(例如Accept,Accept-Language,Accept-Charset)之外的方面选择响应。



实际上,这告诉缓存不要缓存响应。这就是对该资源的后续请求只能由原始服务器正确解释的含义。缓存必须将这些请求转发到源服务器。



编辑:Vary与缓存正交。考虑一下:



GET / foo HTTP / 1.1



200 Ok
缓存控制:maxage = 60
内容 - 位置:/foo.html
变化:*



变化:*告诉缓存无法缓存响应请求/ foo中。但由于Content-Location标头,缓存仍然可以将请求的响应存储到/foo.html。


As far as I know, the HTTP Header Vary specifies a comma separated list of HTTP headers that need to be considered by caches together with the URL when deciding if a request is a cache hit or miss.

If that header is omitted, means that only the URL will be considered.

But what happen when the header is Vary:* ?

RFC 2616 14.4

A Vary field value of *** signals that unspecified parameters not limited to the request-headers (e.g., the network address of the client), play a role in the selection of the response representation. The * value MUST NOT be generated by a proxy server; it may only be generated by an origin server.

RFC 2616 13.6

A Vary header field-value of * always fails to match and subsequent requests on that resource can only be properly interpreted by the origin server.

Does it means that all requests with this header are going to be a cache miss?

I find out that ASP.NET is returning that HTTP header if you use their OutputCacheAttribute, and you have to disable explicitly that behaviour if you don't want the header, or you want to specify custom headers, so I (want to) believe it is unlikely.

Which is the practical meaning of Vary:* ?

Thanks.

解决方案

Vary:* tells caches that the response has been chosen based on aspects beyond the usual aspects of HTTP content negotiation (e.g. Accept, Accept-Language, Accept-Charset).

Effectively this tells the cache not to cache the response. That is the meaning of "subsequent requests on that resource can only be properly interpreted by the origin server". The cache must forward these requests to the origin server.

Edit: Vary is orthogonal to caching. Consider this:

GET /foo HTTP/1.1

200 Ok Cache-Control: maxage=60 Content-Location: /foo.html Vary: *

Vary:* tells caches that the response cannot be cached for requests to /foo. But because of the Content-Location header, caches can still store the response for requests to /foo.html.

这篇关于HTTP标头的含义是什么变化:*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆