gzip compression not taken into account?

Thomas Love tomlove at gmail.com
Sun May 15 01:36:10 MSD 2011


The --compressed flag is adding "Accept-Encoding: deflate, gzip" to the
request.

Your test shows that nginx is working fine. It is compressing the content if
it receives an Accept-Encoding: gzip field, and doesn't if not. This is
valid behaviour.

However, Chrome *should* be sending an Accept-Encoding field just like curl
--compressed. You can confirm this using the dev tools. If it is, and you
don't get a Content-Encoding: gzip header in the response on Chrome
(indicating compression), and if that curl test you performed was run on
local interface to nginx, then it is almost certainly an HTTP proxy that's
interfering.

If otoh, you got those results running the curl test remotely so that it too
went through the proxy (a useful confirmation test if you didn't), then I'm
not so sure.


Cheers
Thomas


On 14 May 2011 18:22, jfix <nginx-forum at nginx.us> wrote:

> Thanks for your replies, I will try to provide more information (I'm
> quite new with nginx).
>
> Traffic passes through the company firewall/proxy server, so potentially
> things could get mangled there.  I guess  there is no way to inspect the
> requested headers as received by the server? I set the error_log level
> to debug_http, but it doesn't seem to log headers.
>
> One interesting detail: Using curl and explicitly requesting a
> compressed response like this, I get this result:
>
> M:>curl -v --compressed http://example.org/
> * About to connect() to example.org port 80 (#0)
> *   Trying xx.xx.xx.xx... connected
> * Connected to example.org (xx.xx.xx.xx) port 80 (#0)
> > GET / HTTP/1.1
> > User-Agent: curl/7.19.7 (i386-pc-win32) libcurl/7.19.7 OpenSSL/0.9.8l
> zlib/1.2.3
> > Host: example.org
> > Accept: */*
> > Accept-Encoding: deflate, gzip
> >
> < HTTP/1.1 200 OK
> < Server: nginx
> < Date: Sat, 14 May 2011 16:10:06 GMT
> < Content-Type: text/html; charset=UTF-8
> < Transfer-Encoding: chunked
> < Connection: keep-alive
> < Vary: Accept-Encoding
> < Content-Encoding: gzip
> <
> 10.107.145.6 - - [14/May/2011:18:10:06 +0000] "GET / HTTP/1.1" 200 2671
> "-" "curl/7.19.7 (i386-pc-win32) libcurl/7.19.7 OpenSSL/0.9.81
> zlib/1.2.3 "-" "0.031" "2.53"
>
> where the last item "2.53" is the compression ratio.
>
> M:>curl -v --compressed http://example.org/resource/style/global.css
> * About to connect() to example.org port 80 (#0)
> *   Trying xx.xx.xx.xx... connected
> * Connected to example.org (xx.xx.xx.xx) port 80 (#0)
> > GET /resource/style/global.css HTTP/1.1
> > User-Agent: curl/7.19.7 (i386-pc-win32) libcurl/7.19.7 OpenSSL/0.9.8l
> zlib/1.2.3
> > Host: example.org
> > Accept: */*
> > Accept-Encoding: deflate, gzip
> >
> < HTTP/1.1 200 OK
> < Server: nginx
> < Date: Sat, 14 May 2011 16:14:38 GMT
> < Content-Type: text/css
> < Transfer-Encoding: chunked
> < Connection: keep-alive
> < Vary: Accept-Encoding
> < Last-Modified: Fri, 13 May 2011 16:00:36 GMT
> < Expires: Thu, 31 Dec 2037 23:55:55 GMT
> < Cache-Control: max-age=315360000
> < Content-Encoding: gzip
>
> 10.107.145.6 - - [14/May/2011:18:14:38 +0000] "GET / HTTP/1.1" 200 7917
> "-" "curl/7.19.7 (i386-pc-win32) libcurl/7.19.7 OpenSSL/0.9.81
> zlib/1.2.3 "-" "0.000" "5.48"
>
> So, this means that compression does work in theory, but it doesn't
> unless I request it. The following example is the same as the previous
> one, but without the --compressed:
>
> M:>curl -v http://example.org/resource/style/global.css
> * About to connect() to example.org port 80 (#0)
> *   Trying xx.xx.xx.xx... connected
> * Connected to example.org (xx.xx.xx.xx) port 80 (#0)
> > GET /resource/style/global.css HTTP/1.1
> > User-Agent: curl/7.19.7 (i386-pc-win32) libcurl/7.19.7 OpenSSL/0.9.8l
> zlib/1.2.3
> > Host: example.org
> > Accept: */*
> >
> < HTTP/1.1 200 OK
> < Server: nginx
> < Date: Sat, 14 May 2011 16:16:59 GMT
> < Content-Type: text/css
> < Connection: keep-alive
> < Vary: Accept-Encoding
> < Content-Length: 43345
> < Last-Modified: Fri, 13 May 2011 16:00:36 GMT
> < Expires: Thu, 31 Dec 2037 23:55:55 GMT
> < Cache-Control: max-age=315360000
>
> 10.107.145.6 - - [14/May/2011:18:16:59 +0000] "GET / HTTP/1.1" 200 43345
> "-" "curl/7.19.7 (i386-pc-win32) libcurl/7.19.7 OpenSSL/0.9.81
> zlib/1.2.3 "-" "0.000" "-"
>
> I'm not sure what the --compressed option translates to in terms of
> headers, but it makes a difference. The last examples is what I get when
> I user a browser (Chrome and Firefox tested).
>
> Thanks for your help,
> Jakob.
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,197898,198024#msg-198024
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20110514/def367b7/attachment-0001.html>


More information about the nginx mailing list