Can proxy_cache gzip cached content?

Massimiliano Mirra hyperstruct at
Sat Feb 18 20:43:11 UTC 2012

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;
>             }

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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list