Welcome! Log In Create A New Profile

Advanced

Re: Can proxy_cache gzip cached content?

February 14, 2012 07:42PM
Thanks for the pointers. As I wrote, I'd rather avoid gzipping in the
backend, but if that's the only option so be it.

I was also concerned about caching gzipped content using the value of
Accept-Encoding in the cache key and ending with many duplicates because of
slightly different yet equivalent headers, but your suggestion to normalize
it solves it nicely.

Cheers,
Massimiliano


On Tue, Feb 14, 2012 at 2:49 PM, rmalayter <nginx-forum@nginx.us> wrote:

> 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;
>
> }
>
>
>
> }
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,222382,222391#msg-222391
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
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: 306
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