使用Nginx启用gzip压缩 [英] enable gzip compression with nginx
问题描述
我正在尝试为我的网站的组件启用gzip压缩.我有ubuntu 11.04服务器和nginx 1.2.
在我的网站的Nginx配置中,我有这个
I am trying to enable gzip compression for components of my website. I have ubuntu 11.04 server and nginx 1.2.
in my nginx configuration of the website, i have this
gzip on;
#gzip_min_length 1000;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;
#it was gzip_buffers 16 8k;
gzip_buffers 128 4k; #my pagesize is 4
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
,Yslow和Google的速度测量建议我使用gzip减少网络传输.
现在,当我尝试curl -I my_js_file
我得到了
and Yslow and google speed measures are advising me to use gzip to reduce transmission over network.
now when i try to curl -I my_js_file
i got
curl -I http://www.albawaba.com/sites/default/files/js/js_367664096ca6baf65052749f685cac7b.js
HTTP/1.1 200 OK
Server: nginx/1.2.0
Date: Sun, 14 Apr 2013 13:15:43 GMT
Content-Type: application/x-javascript
Content-Length: 208463
Connection: keep-alive
Last-Modified: Sun, 14 Apr 2013 10:58:06 GMT
Vary: Accept-Encoding
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Pragma: public
Cache-Control: public
Accept-Ranges: bytes
关于我做错了什么或应该怎么做才能获得压缩内容的任何想法?
any idea of what i have done wrong or what shall i do to get compressed content?
推荐答案
我刚刚将 gzip_http_version 1.1; 更改为 gzip_http_version 1.0; ,然后奏效了
I just changed gzip_http_version 1.1; to be gzip_http_version 1.0; and then it worked
这篇关于使用Nginx启用gzip压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!