Problem with GZIP
Francis Daly
francis at daoine.org
Mon Oct 3 19:24:53 UTC 2011
On Mon, Oct 03, 2011 at 11:09:47AM -0400, firestorm wrote:
Hi there,
> and the problem remains.
It works for me.
So there is some difference in our configurations.
I've copied your original gzip* configuration, and added "expires max"
to the relevant location, since the logs suggest you are using that too.
While testing, I suggest you simplify the configuration until you find
what changes makes it go from not-working to working, or the other
way around.
With the following nginx:
$ sbin/nginx -V
nginx: nginx version: nginx/1.1.4
nginx: built by gcc 4.4.5 (Debian 4.4.5-8)
nginx: configure arguments: --with-debug
and the following nginx.conf:
$ cat conf/nginx.conf
events {
worker_connections 1024;
debug_connection 127.0.0.1;
}
http {
include mime.types;
gzip on;
gzip_min_length 1000;
gzip_comp_level 6;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml;
server {
listen 8000;
location / {
expires max;
}
}
}
I can see the result of the following commands:
$ curl -v --compressed http://localhost:8000/a.txt >/dev/null
* About to connect() to localhost port 8000 (#0)
* Trying 127.0.0.1... % Total % Received % Xferd Average Speed Time Time
Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0connected
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /a.txt HTTP/1.1
> User-Agent: curl/7.21.0 (i486-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
> Host: localhost:8000
> Accept: */*
> Accept-Encoding: deflate, gzip
>
< HTTP/1.1 200 OK
< Server: nginx/1.1.4
< Date: Mon, 03 Oct 2011 19:14:08 GMT
< Content-Type: text/plain
< Last-Modified: Mon, 03 Oct 2011 19:03:51 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Expires: Thu, 31 Dec 2037 23:55:55 GMT
< Cache-Control: max-age=315360000
< Content-Encoding: gzip
<
{ [data not shown]
100 1028 0 1028 0 0 51451 0 --:--:-- --:--:-- --:--:-- 57111* Connection #0 to host localhost left intact
* Closing connection #0
which shows that my text/plain was compressed ("Content-Encoding: gzip"
in the response headers); and
$ curl -v --compressed http://localhost:8000/a.css >/dev/null
* About to connect() to localhost port 8000 (#0)
* Trying 127.0.0.1... % Total % Received % Xferd Average Speed Time Time
Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0connected
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /a.css HTTP/1.1
> User-Agent: curl/7.21.0 (i486-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
> Host: localhost:8000
> Accept: */*
> Accept-Encoding: deflate, gzip
>
< HTTP/1.1 200 OK
< Server: nginx/1.1.4
< Date: Mon, 03 Oct 2011 19:15:36 GMT
< Content-Type: text/css
< Content-Length: 2726
< Last-Modified: Mon, 03 Oct 2011 19:03:51 GMT
< Connection: keep-alive
< Expires: Thu, 31 Dec 2037 23:55:55 GMT
< Cache-Control: max-age=315360000
< Accept-Ranges: bytes
<
{ [data not shown]
100 2726 100 2726 0 0 487k 0 --:--:-- --:--:-- --:--:-- 887k* Connection #0 to host localhost left intact
* Closing connection #0
which shows that my text/css output was not compressed.
When I add text/css to the gzip_types line and reload, then my text/css
output shows as compressed.
Get that much working on your system, to prove that your test system is
right, and then add back the desired final configuration in stages.
Good luck with it,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list