What does vary:accept-encoding mean?(变化:接受编码是什么意思?)
问题描述
谷歌页面速度插件通知我:
the google page speed addon informs me:
The following publicly cacheable, compressible resources should have a "Vary: Accept-Encoding" header:
//some .js and .css files
我不明白这是什么意思.我已经像这样压缩了这些文件:
I don't understand what this means. I've already compressed these files like so:
if (encodings.Contains("gzip") || encodings == "*")
{
app.Response.Filter = new GZipStream(baseStream, CompressionMode.Compress);
app.Response.AppendHeader("Content-Encoding", "gzip");
}
这一切似乎都奏效了.为什么需要 Vary: Accept-Encoding
?
And this all seems to work. Why is having Vary: Accept-Encoding
necessary?
推荐答案
它允许缓存根据浏览器是否请求 GZIP 编码来提供不同的页面缓存版本.如果指示的标头中有任何变化,则可变标头指示缓存存储页面的不同版本.
It is allowing the cache to serve up different cached versions of the page depending on whether or not the browser requests GZIP encoding or not. The vary header instructs the cache to store a different version of the page if there is any variation in the indicated header.
就目前而言,缓存中将有一个(可能是压缩的)页面副本.假设它是压缩版本:如果有人请求资源但不支持 gzip 编码,则会为他们提供错误的内容.
As things stand, there will be one (possibly compressed) copy of the page in cache. Say it is the compressed version: If somebody requests the resource but does not support gzip encoding, they'll be served the wrong content.
这篇关于变化:接受编码是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:变化:接受编码是什么意思?


基础教程推荐
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01