Welcome! Log In Create A New Profile

Advanced

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

April 28, 2010 11:40AM
Hi Igor,

On Tue, Apr 27, 2010 at 11:25 PM, Igor Sysoev <igor@sysoev.ru> wrote:
>> Any ideas why/where the .js is not getting gzipped?

> You may set on it on nginx side:
> proxy_set_header Accept-Encoding "";

Done. Thanks.

> In your examples .js response has 304 code without body, so here is
> nothing to gzip, and .gif response has 404 code and it is not image,
> but text/html, so it is gzipped.

Yup. Those 304s were a result of local caching in the client.
Cleared that, and retried -- getting 200s, as expected, BUT, still no
js gzip.

Turns out that there was another issue, caught @ varnish list ...
namely, that the js is being served with Content-Type: text/x-js --
which was NOT added to the nginx gzip-types.

The cause is,

grep js /etc/apache2/mime.types
application/javascript js
text/x-js js

defined in the standard distro-release of apache2. not mentioned at
all in the rfc (http://www.ietf.org/rfc/rfc4329.txt), but widely used,
apparently, nonetheless. so, added it to gzip types, and tried again.


now, headers show BOTH js & css being compressed, as intended,

----------------------------------------------------------
https://my.site.com/apostrophePlugin/js/jquery.autogrow.js


GET /apostrophePlugin/js/jquery.autogrow.js HTTP/1.1
Host: my.site.com
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.4) Gecko/20100417
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: https://my.site.com/
Cookie: symfony=R%2Cq-BqTdX-ckfGCqHa2MnDsbJpd

HTTP/1.1 200 OK
Server: nginx/0.8.35
Date: Wed, 28 Apr 2010 15:09:34 GMT
Content-Type: text/x-js
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Last-Modified: Wed, 28 Apr 2010 04:42:23 GMT
Etag: "267f6-db6-48544a2d549c0"
Cache-Control: max-age=259200
Expires: Sat, 01 May 2010 15:09:34 GMT
X-Varnish: 1289869751 1289869733
Age: 283
Via: 1.1 varnish
Content-Encoding: gzip

----------------------------------------------------------
https://my.site.com/apostrophePlugin/css/a.css

GET /apostrophePlugin/css/a.css HTTP/1.1
Host: my.site.com
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.4) Gecko/20100417
Accept: text/css,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: https://my.site.com/
Cookie: symfony=R%2Cq-BqTdX-ckfGCqHa2MnDsbJpd

HTTP/1.1 200 OK
Server: nginx/0.8.35
Date: Wed, 28 Apr 2010 15:09:34 GMT
Content-Type: text/css
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Last-Modified: Wed, 28 Apr 2010 04:42:21 GMT
Etag: "26233-14e26-48544a2b6c540"
Cache-Control: max-age=259200
Expires: Sat, 01 May 2010 15:09:34 GMT
X-Varnish: 1289869748
Age: 0
Via: 1.1 varnish
Content-Encoding: gzip

----------------------------------------------------------

AND, the YSlow plugin now 'grades' the page an "A".

> BTW, why do you use varnish instead of nginx built-in proxy cache ?

I'd originally had Pound in front of varnish; Nginx was a logical
choice to replace it, as a first step.

As for using it as a proxy cache ... Varnish provides all in-memory
caching. I simply don't know if nginx.

Also, I use Varnish to provide a content-based parallel CDN. Attempts
to do it with nginx failed, and, it appeared others were having issue
as well (http://groups.drupal.org/node/48182). The nginx + varnish
solution works well.

> BTW, in 0.7.12+ you may use
> gzip_disable msie6;
> instead of
> gzip_disable "MSIE [1-6].(?!.*SV1)";
> It's faster.

Missed that one completely. Thanks.

> Also, "gzip_comp_level 1" is enough. 9th level simply eats more CPU, but
> do not produce proportional cmpression ratio. Say, 1 decreases file 2 times
> while 9 - only 2.5, but not 5 times.

I didn't realize that the difference was _that_ small ...

Thanks for the help!

Ben

>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

BenDJ April 27, 2010 09:12PM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

Igor Sysoev April 28, 2010 02:30AM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

Igor Sysoev April 28, 2010 02:36AM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

BenDJ April 28, 2010 11:40AM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

Igor Sysoev April 28, 2010 03:18PM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

BenDJ April 28, 2010 03:36PM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

Igor Sysoev April 28, 2010 03:46PM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

BenDJ April 28, 2010 04:00PM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

Guillaume Filion April 28, 2010 12:30PM

Re: nginx compression-at-edge (in front of a reverse proxy) compresses some content, not other ?

BenDJ April 28, 2010 12:30PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 283
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready