0

当我加载 Google 的托管jquery.min.js时,它不会返回 gzipped:


请求标头

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Cache-Control:max-age=0
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22

响应标头

Age:262255
Cache-Control:public, max-age=31536000
Content-Length:91668
Content-Type:text/javascript; charset=UTF-8
Date:Fri, 11 Nov 2011 13:06:19 GMT
Expires:Sat, 10 Nov 2012 13:06:19 GMT
Last-Modified:Thu, 22 Sep 2011 14:12:07 GMT
Server:sffe
Vary:Accept-Encoding
X-Content-Type-Options:nosniff
X-XSS-Protection:1; mode=block

有趣的是,确实jquery-ui.min.js


请求标头

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Cache-Control:max-age=0
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22

响应标头

Cache-Control:private, x-gzip-ok="", max-age=31536000
Content-Encoding:gzip
Content-Length:52140
Content-Type:text/javascript; charset=UTF-8
Date:Mon, 14 Nov 2011 13:55:50 GMT
Expires:Mon, 14 Nov 2011 13:55:50 GMT
Last-Modified:Thu, 22 Sep 2011 14:12:07 GMT
Server:sffe
Vary:Accept-Encoding
X-Content-Type-Options:nosniff
X-XSS-Protection:1; mode=block

这是怎么回事?

我发现一篇声称谷歌无视Accept-EncodingUser-Agent决定是否压缩的文章。这并不能解释为什么 Mac OS X 上最新的 Safari 和 Chrome 会获得未压缩的 jQuery(和压缩的 jQuery UI)。

4

1 回答 1

2

这是我的请求标头:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding:gzip, deflate
Accept-Language:en-gb,en;q=0.5
Connection:keep-alive
Host:ajax.googleapis.com
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0

我得到以下响应标头:

Cache-Control: private, x-gzip-ok="", max-age=31536000
Content-Encoding: gzip
Content-Length: 32103
Content-Type: text/javascript; charset=UTF-8
Date: Mon, 14 Nov 2011 13:28:31 GMT
Expires: Mon, 14 Nov 2011 13:28:31 GMT
Last-Modified: Thu, 22 Sep 2011 14:12:07 GMT
Server: sffe
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-XSS-Protection:1; mode=block

看起来它默认是 gzip,只要编码被接受。

于 2011-11-14T13:30:47.120 回答