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.
这篇关于变化:接受编码是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:变化:接受编码是什么意思?


- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 输入按键事件处理程序 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01