Welcome! Log In Create A New Profile

Advanced

Re: Can proxy_cache gzip cached content?

February 14, 2012 08:49AM
Just make sure the "Accept-Encoding: gzip" is being passed to your back-end, and let the back end do the compression. We actually normalize the Accept-Encoding header as well with an if statement. Also use the value of the Accept-Encoding header in your proxy_cache_key. This allows non-cached responses for those clients that don't support gzip (usually coming through an old, weird proxy). So you will get both compressed and uncompressed versions in your cache, but with our clients it's like 99% compressed versions at any one time.

Example:

server {

#your server stuff here

#normalize all accept-encoding headers to just gzip
set $myae "";
if ($http_accept_encoding ~* gzip) {
set $myae "gzip";
}

location / {
proxy_pass http://backend;
#the following allows comressed responses from backend
proxy_set_header Accept-Encoding $myae;

proxy_cache zone1;
proxy_cache_key "$request_uri $myae";
proxy_cache_valid 5m;
proxy_cache_use_stale error updating;

}



}
Subject Author Posted

Can proxy_cache gzip cached content?

bard February 14, 2012 07:08AM

Re: Can proxy_cache gzip cached content?

rmalayter February 14, 2012 08:49AM

Re: Can proxy_cache gzip cached content?

bard February 14, 2012 07:42PM

Re: Can proxy_cache gzip cached content?

rmalayter February 15, 2012 09:55AM

Re: Can proxy_cache gzip cached content?

bard February 17, 2012 08:04AM

Re: Can proxy_cache gzip cached content?

bard February 18, 2012 03:44PM

Re: Can proxy_cache gzip cached content?

Maxim Dounin February 18, 2012 06:32PM

Re: Can proxy_cache gzip cached content?

bard February 19, 2012 05:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 77
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