QQ群web前端分析一——准备部分

Vary:Accept-Encoding的用途  

2012-09-06 11:47:08|  分类: rhel_apache|字号 订阅

 
 

查看网页的response header一般都有Vary头(服务器支持压缩的都有),意思是说squid要把客户端传来的某个头区别对待,譬如Vary:Accept-Encoding,客户端发来Accept-Encoding:gzip(MSIE), deflate时squid会为gzip, deflate做一个存档;如果客户端没发来Accept-Encoding这个头(wget),squid又会为无Accept-Encoding做另一个存档;这两个存档的内容是不一样的,gzip, deflate的是压缩后的内容,一堆乱码,无Accept-Encoding的则是网页源码。

知道了Vary的原理,剩下的事就容易了,在网页输出时加上Vary:User-Agent,意味着squid要为每一种User-Agent存一个存档,nginx里这样配置即可:

add_header Vary Accept-Encoding;

这时网页的response header会有Vary:

Vary:Accept-Encoding;

引用出处:http://zhumeng8337797.blog.163.com/blog/static/10076891420128611478976/

Squid: Optimising Web Delivery

Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. It runs on most available operating systems, including Windows and is licensed under the GNU GPL.

 

SQUID是个缓存代理服务器

posted @ 2013-09-25 08:54  web 的世界  阅读(271)  评论(0编辑  收藏  举报