gzip enabling for selective browsers

Steve Chu stvchu at gmail.com
Wed Sep 5 19:39:37 MSD 2007


We try to use ngx_http_gzip_module in our high-load site serving for
static js and css files. But that run a very high cpu level, seems
that no gzipped file cache in local, it just compresses instantly
every request.

Is there any planned feature of ngx_http_gzip_module that for local cache?

On 9/5/07, Igor Sysoev <is at rambler-co.ru> wrote:
> On Wed, Sep 05, 2007 at 10:57:57PM +0800, Steve Chu wrote:
>
> > 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 },
>
> There is no need to add this variable because it already exists:
> any client header is available as $http_... Some frequently used variables
> such as $http_host, $http_user_agent, etc. are defined explicitly in
> ngx_http_variables.c to speed up search.
>
> > So, you can using in configure file:
> >
> > if ($http_accept_encoding ~* "gzip") {
> >        ...
> >    }
>
> ngx_http_gzip_module always tests "Accept-Encoding" for gzip, so
> this test is not needed.
>
> > 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
> >
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>


-- 
Steve Chu
http://stvchu.org





More information about the nginx mailing list