Vary

这篇翻译不完整。请帮忙从英语翻译这篇文章

Vary 是一个HTTP响应头部信息,它决定了对于未来的一个请求头,应该用一个缓存的回复(response)还是向源服务器请求一个新的回复。它被服务器用来表明在 content negotiation algorithm(内容协商算法)中选择一个资源代表的时候应该使用哪些头部信息(headers).

The Vary header should be set on a 304 Not Modified response exactly like it would have been set on an equivalent 200 OK response.

Header type Response header
Forbidden header name no

Syntax

Vary: *
Vary: <header-name>, <header-name>, ...

Directives

*
Each request for a URL is supposed to be treated as a unique and uncacheable request. A better way to indicate this is to use Cache-Control: private, which is clearer to read and also signals that the object shouldn't be stored ever.
<header-name>
A comma-separated list of header names to take into account when deciding whether or not a cached response can be used.

Examples

Dynamic serving

When using the Vary: User-Agent header, caching servers should consider the user agent when deciding whether to serve the page from cache. For example, if you are serving different content to mobile users, it can help you to avoid that a cache may mistakenly serve a desktop version of your site to your mobile users. It can help Google and other search engines to discover the mobile version of a page, and might also tell them that no Cloaking is intended.

Vary: User-Agent

Specifications

Specification Title
RFC 7231, section 7.1.4: Vary Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

Browser compatibility

Feature Chrome Edge Firefox Internet Explorer Opera Safari Servo
Vary(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)
Feature Android Chrome for Android Edge Mobile Firefox for Android IE Mobile Opera Mobile Safari Mobile
Vary(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)

Compatibility notes

See also

文档标签和贡献者

 此页面的贡献者: newhuan
 最后编辑者: newhuan,