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)";
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?
You need to run:
to make curl send an Accept-Encoding header for gzip - the server will only compress content if the client sends a header saying it will accept it.
NB you can write:
rather than using a regex to disable in IE 5.5 and 6, and you needn't specify text/html as a type because it is always compressed as long as gzip is activated.
I had to enable gzip in my
/etc/nginx/nginx.conf
configuration:Please note that I had to add
application/javascript
to the standardgzip_types
configuration.Just like Alaa I had to add
gzip_http_version 1.0;
(no version was previously specified) for it to work (I tried on Firefox 27.0.0).