apache中这个配置是什么意思?

发布于 2024-07-22 22:31:27 字数 1459 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半衬遮猫 2024-07-29 22:31:27

这使用 Apache mod_headers 将值“User-Agent”附加到改变 HTTP 标头,但前提是未设置 dont-vary 环境。

但 Vary 标头是什么? 请参阅 RFC2616 ,其中表示

Vary字段值表示集合
请求标头字段的数量完全
确定,而响应是
fresh,是否允许缓存
使用响应来回复
后续请求没有
重新验证

如果您根据 User-Agent 标头提供不同的 HTML 标记,则可以使用其中包含 User-Agent 的 Vary 标头来确保缓存代理不会向浏览器 Y 提供用于浏览器 X 的内容。

This uses Apache mod_headers to append the value "User-Agent" to the Vary HTTP header, but only if the dont-vary environment is not set.

But what is the Vary header? See RFC2616 which says

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

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.

花想c 2024-07-29 22:31:27

请参阅 mod_headers 文档中的标头指令

这指示 Web 服务器将 Vary 标头的新值附加Vary 标头的任何先前值(将新值与旧值以逗号分隔)或为 Vary 标头创建新值。 要创建或附加的新值将为user-agent。 仅当执行 apache 服务的环境中未定义 dont-vary 环境变量时,才会创建/附加此标头。

总而言之,如果 dont-vary 环境变量存在,服务器将发出如下内容:

Vary: ...,user-agent

See the Header directive in the mod_headers documentation.

This instructs the web server to append the new value of the Vary header to any previous value of the Vary header (separating the new value from the old one by a comma) or to create a new value for the Vary header. The new value to be created or appended will be user-agent. This header will only be created/appended if the dont-vary environment variable is undefined within the environment of the executing apache service.

To summarize, if the dont-vary environment variable does not exist, the server will issue out something like this:

Vary: ...,user-agent
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文