# Nginx gzip\_static not following gzip\_types

**URL:** <https://www.ruby-forum.com/t/nginx-gzip-static-not-following-gzip-types/219217>\
**Category:** NGINX\
**Created:** [April 24, 2012, 8:14am UTC](https://www.ruby-forum.com/t/nginx-gzip-static-not-following-gzip-types/219217 "2012-04-24T08:14:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 24, 2012, 8:14am UTC](https://www.ruby-forum.com/t/nginx-gzip-static-not-following-gzip-types/219217/1 "2012-04-24T08:14:40Z")

</div>

The directive gzip\_static does not follow the rules in gzip\_types

```
gzip on;
gzip_static on;
gzip_http_version 1.0;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_comp_level 5;
gzip_min_length 1000;
gzip_vary on;
gzip_buffers 64 16k;
gzip_types text/plain application/xml text/css

```

application/javascript application/x-javascript text/javascript;

#strace

open(“/var/www/forum/images/smilies/attention.gif.gz”,  
O\_RDONLY|O\_NONBLOCK) = -1 ENOENT (No such file or directory)  
open(“/var/www/forum/images/smilies/lookoutbelow.gif”,  
O\_RDONLY|O\_NONBLOCK) = 319  
open(“/var/www/forum/images/smilies/lookoutbelow.gif.gz”,  
O\_RDONLY|O\_NONBLOCK) = -1 ENOENT (No such file or directory)  
open(“/var/www/forum/images/smilies/heresyoursign.gif”,  
O\_RDONLY|O\_NONBLOCK) = 320  
open(“/var/www/forum/images/smilies/heresyoursign.gif.gz”,  
O\_RDONLY|O\_NONBLOCK) = -1 ENOENT (No such file or directory)  
open(“/var/www/forum/images/smilies/woohooo.gif”, O\_RDONLY|O\_NONBLOCK) =  
321  
open(“/var/www/forum/images/smilies/woohooo.gif.gz”,  
O\_RDONLY|O\_NONBLOCK) = -1 ENOENT (No such file or directory)  
open(“/var/www/forum/images/smilies/ohno.gif”, O\_RDONLY|O\_NONBLOCK) =  
322  
open(“/var/www/forum/images/smilies/ohno.gif.gz”, O\_RDONLY|O\_NONBLOCK) =  
-1 ENOENT (No such file or directory)

As you can see, it is looking for .gz images even though the gzip\_types  
excludes images.

Posted at Nginx Forum:

> **[nginx gzip\_static not following gzip\_types](https://forum.nginx.org/read.php?2,225692,225692#msg-225692)**
>
> The directive gzip\_static does not follow the rules in gzip\_types gzip on; gzip\_static on; gzip\_http\_version 1.0; gzip\_disable "MSIE \[1-6\]\\.(?!.\*SV1)"; gzip\_comp\_level 5; gzip\_min\_length 1000; gzip

---

<div class="post-metadata">

**Author:** ![ctrlbrk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/73ab20/32.png) [@ctrlbrk](https://www.ruby-forum.com/u/ctrlbrk)\
**Post date:** [April 24, 2012, 8:24am UTC](https://www.ruby-forum.com/t/nginx-gzip-static-not-following-gzip-types/219217/2 "2012-04-24T08:24:34Z")

</div>

Hello!

On Tue, Apr 24, 2012 at 02:13:54AM -0400, ctrlbrk wrote:

> The directive gzip\_static does not follow the rules in gzip\_types

Yes, and it’s documented behaviour, actually:

> **[Module ngx\_http\_gzip\_static\_module](http://nginx.org/en/docs/http/ngx_http_gzip_static_module.html#gzip_static)**
>
> The ngx\_http\_gzip\_static\_module module allows sending precompressed files with the “.gz” filename extension instead of regular files.

: The following directives are also taken into account:  
: gzip\_http\_version, gzip\_proxied, gzip\_disable, and gzip\_vary.

Maxim D.

---

<div class="post-metadata">

**Author:** ![ctrlbrk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/73ab20/32.png) [@ctrlbrk](https://www.ruby-forum.com/u/ctrlbrk)\
**Post date:** [April 24, 2012, 8:36am UTC](https://www.ruby-forum.com/t/nginx-gzip-static-not-following-gzip-types/219217/3 "2012-04-24T08:36:22Z")

</div>

Thanks for the quick reply. It would be nice if there was a simple top  
level directive added to make it follow the gzip\_types rule. The  
default behavior of trying to compress images is pretty futile. Even if  
I had my bash script compress images to serve up, the extra  
decompression time on the client would cause the page to be slower, and  
bandwidth savings of probably less than 1% at expense of much, much more  
than 1% increased client CPU.

Posted at Nginx Forum:

> **[Re: nginx gzip\_static not following gzip\_types](https://forum.nginx.org/read.php?2,225692,225695#msg-225695)**
>
> The directive gzip\_static does not follow the rules in gzip\_types gzip on; gzip\_static on; gzip\_http\_version 1.0; gzip\_disable "MSIE \[1-6\]\\.(?!.\*SV1)"; gzip\_comp\_level 5; gzip\_min\_length 1000; gzip

---

<div class="post-metadata">

**Author:** ![ctrlbrk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/73ab20/32.png) [@ctrlbrk](https://www.ruby-forum.com/u/ctrlbrk)\
**Post date:** [April 24, 2012, 10:34am UTC](https://www.ruby-forum.com/t/nginx-gzip-static-not-following-gzip-types/219217/4 "2012-04-24T10:34:56Z")

</div>

On Tue, Apr 24, 2012 at 02:36:07AM -0400, ctrlbrk wrote:

> Thanks for the quick reply. It would be nice if there was a simple top  
> level directive added to make it follow the gzip\_types rule. The  
> default behavior of trying to compress images is pretty futile. Even if  
> I had my bash script compress images to serve up, the extra  
> decompression time on the client would cause the page to be slower, and  
> bandwidth savings of probably less than 1% at expense of much, much more  
> than 1% increased client CPU.

location /images/ {  
gzip\_static off;  
…  
}

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![ctrlbrk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/73ab20/32.png) [@ctrlbrk](https://www.ruby-forum.com/u/ctrlbrk)\
**Post date:** [April 24, 2012, 10:47am UTC](https://www.ruby-forum.com/t/nginx-gzip-static-not-following-gzip-types/219217/5 "2012-04-24T10:47:57Z")

</div>

Hello!

On Tue, Apr 24, 2012 at 02:36:07AM -0400, ctrlbrk wrote:

> Thanks for the quick reply. It would be nice if there was a simple top  
> level directive added to make it follow the gzip\_types rule. The  
> default behavior of trying to compress images is pretty futile. Even if  
> I had my bash script compress images to serve up, the extra  
> decompression time on the client would cause the page to be slower, and  
> bandwidth savings of probably less than 1% at expense of much, much more  
> than 1% increased client CPU.

It doesn’t try to compress anything, it’s up to you to compress  
files you think is ok to compress. The gzip\_static just checks if  
a ‘.gz’ file present, and returns it to client if it’s present  
(and client supports gzip).

If you want to avoid file lookup, you may (and probably should)  
disable gzip\_static for locations you don’t want lookup to happen.

Maxim D.
