gzip not working for some files using nginx

shakalandy asked:

Some files are not gzipped on their way to the user browser in our setup.

for example

http://myhostname.com/css/build/20120904-1.css

http://myhostname.com/js/dojo/dn/main.js?20120904-1

http://myhostname.com/js/jquery-min/compiled.js?20120725-4

can not be zipped.

my current configuration:

        location ~* .(js|css|png|jpg|jpeg|gif|ico).*+$ {
            if ($args ~ [0-9].*+) {
               expires max;
               break;
            }
            expires max;
            log_not_found off;
             gzip  on;
    }

What needs to be adjusted to make gzip fly?
I already tried several other options but don’t want to continue with try&error on this.

Thank you very much.

Some more info:
maybe there is another problem.
Firebug and pingdom tools show me the compressed size whereas Chrome Developer Bar and Google PageSpeed Insights says “no compression active”

To make things easier, the link to the site is http://diginights.com

My answer:


That’s because your configuration seems to be telling it not to do so for any file with a digit 0-9 in the name.

Delete this entire section; it’s mostly redundant anyway, and almost certainly isn’t doing anything that you might want.

        if ($args ~ [0-9].*+) {
           expires max;
           break;
        }

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.