ASP.NET MVC 3 网站优化总结(三)Specify Vary: Accept-Encoding header
Posted on 2016-12-21 06:25 WebEnh 阅读(232) 评论(0) 收藏 举报继续进行 ASP.NET MVC 3 网站优化工作,使用 Google Page 检测发现提示 You should Specify Vary: Accept-Encoding header,The following publicly cacheable, compressible resources should have a "Vary: Accept-Encoding" header。
相信很多人遇到过这个问题,它是什么意思呢?网上找到的资料为:
原来对CSS和JS文件开启Gzip后,会输出两份文件:Gzip压缩过的、未经Gzip压缩的,这样一来不仅没加快网页加载速度,反而更慢了;而 Vary: Accept-Encoding header 的作用就是指定输出压缩过的那部分文件。这样一来,Gzip压缩才算是真正起了作用。
解决的方法为在 configuration 节点下添加下边的代码片断即可:
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="Vary"></remove>
<add name="Vary" value="Accept-Encoding"></add>
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
重新运行网站,发现此问题已经解决,如下图:

这样我们的 ASP.NET MVC 3 网站性能又提升了一下,下篇我们会看看 ASP.NET MVC 3 中缓存的使用。
转自:http://Www.CnBlogs.Com/WebEnh/
如果想下次快速找到我,记得点下面的关注哦!
| 本博客Android APP 下载 |
![]() |
| 支持我们就给我们点打赏 |
![]() |
| 支付宝打赏 支付宝扫一扫二维码 |
![]() |
| 微信打赏 微信扫一扫二维码 |
![]() |
如果想下次快速找到我,记得点下面的关注哦!




浙公网安备 33010602011771号