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.
这篇关于变化:接受编码是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:变化:接受编码是什么意思?
基础教程推荐
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- MS Visual Studio .NET 的替代品 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01