file size gzip size file
js 217.4K 217.4K js/scripts-0004.min.js
css 53.3K 53.3K css/style-0004.min.css
为什么gzip
返回相同大小的文件?
他们需要额外的包gzip
吗ubuntu 12.04 + python + nginx server
?
nginx.conf
http {
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
}
>>> r = urllib2.urlopen(urllib2.Request('/style-0004.min.css', ... headers={'Accept-Encoding': 'gzip;q=1.0, *;q=0'}))
>>> print r.info()
Server: nginx/1.1.19 Date: Thu, 13 Dec 2012 11:21:53 GMT
Content-Type: text/css
Transfer-Encoding: chunked Connection: close Vary: Accept-Encoding
Expires: Thu, 31 Dec 2037 23:55:55 GMT
X-UA-Compatible: IE=Edge,chrome=1
Content-Encoding: gzip
>>> s = r.read()
>>> print("comressed size: %d" % len(s))
comressed size: 12231
>>> f = gzip.GzipFile(fileobj=BytesIO(s))
>>> print("uncompressed: %d" % len(f.read()))
uncompressed: 53337
js file. comressed size: 63975 uncompressed: 217473