如果您根据 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.
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:
发布评论
评论(2)
这使用 Apache mod_headers 将值“User-Agent”附加到改变 HTTP 标头,但前提是未设置 dont-vary 环境。
但 Vary 标头是什么? 请参阅 RFC2616 ,其中表示
如果您根据 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
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.
请参阅 mod_headers 文档中的标头指令。
这指示 Web 服务器将 Vary 标头的新值附加到 Vary 标头的任何先前值(将新值与旧值以逗号分隔)或为 Vary 标头创建新值。 要创建或附加的新值将为user-agent。 仅当执行 apache 服务的环境中未定义 dont-vary 环境变量时,才会创建/附加此标头。
总而言之,如果 dont-vary 环境变量不存在,服务器将发出如下内容:
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: