Welcome! Log In Create A New Profile

Advanced

Re: Can proxy_cache gzip cached content?

Maxim Dounin
February 18, 2012 06:32PM
Hello!

On Sat, Feb 18, 2012 at 09:43:11PM +0100, Massimiliano Mirra wrote:

> About this:
>
>
> > location /proxied-stuff {
> > proxy_set_header Accept-Encoding gzip;
> > proxy_cache_key "$scheme$host$request_uri";
> > proxy_cache_valid 2d;
> > proxy_cache myapp_cache;
> > proxy_pass http://127.0.0.1:85;
> > }
> >
>
> I was hoping that gunzip'ping for clients that don't support compression
> would be as simple as adding the following inside the above block:
>
> if ($http_accept_encoding !~* gzip) {
> gunzip on;
> }
>
> But when nginx configuration is reloaded, I get: "nginx: [emerg] "gunzip"
> directive is not allowed here".
>
> I suppose I could rewrite the request to an internal location, then within
> that location's block re-set the proxy_cache_key accordingly. But perhaps
> there's an easier way?

Yes. The easier way is to just write

gunzip on;

It will gunzip responses for clients which don't support gzip (as per
Accept-Encoding and gzip_http_version/gzip_proxied/gzip_disabled,
i.e. the same checks as done for gzip and gzip_static).

Maxim Dounin

_______________________________________________
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: 173
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