Welcome! Log In Create A New Profile


Re: Gziping static files

August 11, 2011 09:50AM
sarim Wrote:
> Ryan Malayter Wrote:
> --------------------------------------------------
> -----
> > nginx server on port 80/443 listening on
> > public-facing IP
> > proxy_cache enabled
> > gzip enabled
> > |
> > V
> > nginx server on localhost port 20080
> > gzip enabled
> > |
> > V
> > your back-end server
> Just tried to do that, but nginx is not caching
> gziped files. It caches in un-gziped state, so
> nginx gziping on every hit :(

The middle tier needs to have gzip enabled, as well as the front-end tier. You will also need to enable gzip for HTTP 1.0 on the middle tier using "gzip_http_version 1.0;" This is because nginx uses HTTP 1.0 to talk with back-end servers (which in this case is nginx itself). Finally, consider normalizing the gzip headers and adding it to your proxy_cache_key at the frontmost layer, like so:

#normalize all incoming accept-encoding headers to just gzip or empty string
#prevents caching of multiple versions of files based on differing browser accept-encoding headers
set $myae ""; #use empty string if accept-encoding does not contain gzip
if ($http_accept_encoding ~* gzip) {
set $myae "gzip";
location <whatever> {
proxy_pass http://localhost:20080; #middle tier doing compression
proxy_set_header Host $host;
proxy_set_header Accept-Encoding $myae;
proxy_cache zone1;
proxy_cache_key "$request_uri $myae"; #use normalized accept encoding as part of cache key
Subject Author Posted

Gziping static files

sarim July 15, 2011 04:29AM

Re: Gziping static files

Ryan Malayter July 26, 2011 10:40AM

Re: Gziping static files

sarim August 11, 2011 05:44AM

Re: Gziping static files

rmalayter August 11, 2011 09:50AM

Re: Gziping static files

Akins, Brian July 26, 2011 12:00PM

Re: Gziping static files

sarim August 11, 2011 10:03AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready