apache apache中的这个配置是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/970798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what does this configuration in apache mean?
提问by omg
Header append Vary User-Agent env=!dont-vary
Can anyone give a detailed explanation for this?
任何人都可以对此进行详细解释吗?
回答by Paul Dixon
This uses Apache mod_headersto append the value "User-Agent" to the Vary HTTP header, but only if the dont-vary environment is not set.
这使用 Apache mod_headers将值“User-Agent”附加到 Vary HTTP 标头,但前提是未设置 dont-vary 环境。
But what is the Vary header? See RFC2616which says
但是什么是 Vary 标头?请参阅RFC2616,其中说
The Vary field value indicates the set of request-header fields that fully determines, while the response is fresh, whether a cache is permitted to use the response to reply to a subsequent request without revalidation
Vary 字段值表示一组请求头字段,当响应是新鲜的时,它完全确定是否允许缓存使用响应来回复后续请求而无需重新验证
If you deliver different HTML markup depending on the User-Agent header, you might use a Vary header with User-Agent in it to ensure that a caching proxy didn't serve content intended for browser X to browser Y.
如果您根据 User-Agent 标头提供不同的 HTML 标记,您可能会使用带有 User-Agent 的 Vary 标头,以确保缓存代理不会向浏览器 Y 提供用于浏览器 X 的内容。
回答by Dathan
See the Header directivein the mod_headers documentation.
请参阅mod_headers 文档中的Header 指令。
This instructs the web server to appendthe new value of the Varyheader to any previous value of the Varyheader (separating the new value from the old one by a comma) or to create a new value for the Varyheader. The new value to be created or appended will be user-agent. This header will only be created/appended if the dont-varyenvironment variable is undefined within the environment of the executing apache service.
这指示Web服务器追加新的价值因人而异头之前的任一值会发生变化头(用逗号分隔从旧的新值)或将创造新的价值因人而异头。要创建或附加的新值将是user-agent。只有在执行 apache 服务的环境中未定义dont-vary环境变量时,才会创建/附加此标头。
To summarize, if the dont-varyenvironment variable does notexist, the server will issue out something like this:
总而言之,如果dont-vary环境变量不存在,服务器将发出如下信息:
Vary: ...,user-agent

