为什么(以及何时)Google CDN提供未压缩的jQuery



当我加载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-Encoding并查看User-Agent来决定是否压缩。这并不能解释为什么Mac OS X上最新的Safari和Chrome使用未压缩的jQuery(以及压缩的jQuery UI)。

这是我的请求头:

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,只要编码被接受。

相关内容

  • 没有找到相关文章

最新更新