이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!
The Vary
HTTP response header determines how to match future request headers to decide whether a cached response can be used rather than requesting a fresh one from the origin server. It is used by the server to indicate which headers it used when selecting a representation of a resource in a content negotiation algorithm.
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
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Servo |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge Mobile | Firefox for Android | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |