变化:接受编码是什么意思?

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.

这篇关于变化:接受编码是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)