gzip enabling for selective browsers

Steve Chu stvchu at gmail.com
Wed Sep 5 18:57:57 MSD 2007


we have added a new variable, "http_accept_encoding".
Just patch the ngx_http_variables.c source file in ngx_http_core_variables[]:

{ ngx_string("http_accept_encoding"), NULL, ngx_http_variable_header,
      offsetof(ngx_http_request_t, headers_in.accept_encoding), 0, 0 },

So, you can using in configure file:

if ($http_accept_encoding ~* "gzip") {
       ...
   }

On 9/5/07, Igor Sysoev <is at rambler-co.ru> wrote:
> On Tue, Sep 04, 2007 at 06:53:32PM +0200, Roxis wrote:
>
> > On Tuesday 04 September 2007, Ezra Zygmuntowicz wrote:
> > >     So nginx cannot selectively gzip based on browser, can it turn off
> > > gzip inside a location /foo {} block?
> >
> > location / {
> >     if ($http_user_agent ~ MSIE) {
> >         gzip off;
> >     }
> > }
>
> It may be set so, but as any configuration inside "if" has drawbacks.
>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>


-- 
Steve Chu
http://stvchu.org





More information about the nginx mailing list