Why is this file not being gzipped?

http://media.xmike.com/css/style.css

    gzip on;
    gzip_static on;
    gzip_proxied any;
    gzip_min_length 1100;
    gzip_buffers 16 8k;
    gzip_comp_level 4;
    gzip_types text/plain text/css application/x-javascript

text/xml application/xml application/xml+rss text/javascript;
gzip_disable “MSIE [1-6].”;
gzip_vary on;

It’s a text/css file. It’s 2331 bytes. Is it too small?
gzip_min_length is set to 1100…

Just wondering.

I did gzip it manually (for gzip_static) and it does work as designed.
But I want to make sure that I’ve got the right configuration down for
normal, non-pre-gzipped files.

Thanks :slight_smile:

On Sat, Aug 23, 2008 at 12:47:22PM -0700, mike wrote:

    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;

It’s a text/css file. It’s 2331 bytes. Is it too small?
gzip_min_length is set to 1100…

Just wondering.

I did gzip it manually (for gzip_static) and it does work as designed.
But I want to make sure that I’ve got the right configuration down for
normal, non-pre-gzipped files.

Could you remove the pre-gzipped file now ?

yes, sorry. removed.

On Sat, Aug 23, 2008 at 10:27:22PM -0700, mike wrote:

yes, sorry. removed.

Yes, it is not compressed. However, in my local tests it’s compressed.
Could you create debug log for this request ?

oh - i am so stupid. i had “gzip off” in that vhost. i didn’t even
bother checking - i turned gzip off for that host to stop the server
from bothering with worrying about gzip.

On Sat, Aug 23, 2008 at 10:57:33PM -0700, mike wrote:

what would be the appropriate regex for

if files do NOT match *.css {
gzip off;
}

server {

gzip off;

locaiton / {
    # static
    ...
}

location ~* \.php$ {
    # fastcgi
    ...
}

location ~* \.css$ {
    gzip on;
}

doesn’t seem to work

    server {
            listen 80;
            server_name media.xmike.com;
            index index.html;
            root /home/mike/web/media.xmike.com/;
        location ~ /\.ht {
              deny all;
      }
     location = /robots.txt {
          log_not_found off;
      }
     location = /favicon.ico {
           log_not_found off;
     }
       server_name_in_redirect off;
       log_not_found off;
       location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html)$ {
                 expires max;
       }
            gzip off;
            location ~* ^.+\.(jpg|jpeg|gif)$ {
                    valid_referers none blocked foo.com;
                    if ($invalid_referer) {
                            return 403;
                    }
            }
            location ~* \.css$ {
                    gzip on;
            }
    }

something wrong there?

On Sat, Aug 23, 2008 at 11:20:02PM -0700, mike wrote:

     location = /robots.txt {
            gzip off;

something wrong there?

css matched by the first location ~*
^.+.(jpg|jpeg|gif|css|png|js|ico|html)$

Use th following:

    location ~* \.css$ {
         gzip on;
         expires max;
    }

    location ~* ^.+\.(jpg|jpeg|gif|png)$ {
         valid_referers none blocked foo.com;
         if ($invalid_referer) {
             return 403;
         }
         expires max;
    }

    location ~* ^.+\.(js|ico|html)$ {
         expires max;
    }

BTW, do you really use such indentions ?
If yes, then I understand Python author.

On 8/23/08, Igor S. [email protected] wrote:

css matched by the first location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$

I fixed it - this is what it looks like now. I keep getting the
location ordering confused. That’s probably the most confusing part of
switching to nginx for me is when something matches multiple
locations/etc… anyway, so far so good!

    server {
            listen 80;
            server_name media.xmike.com;
            index index.html;
            root /home/mike/web/media.xmike.com/;
            gzip off;
            location ~* \.css$ {
                    gzip on;
            }
            include /etc/nginx/defaults.conf;
            include /etc/nginx/expires.conf;
            location ~* ^.+\.(jpg|jpeg|gif)$ {
                    valid_referers none blocked foo.com;
                    if ($invalid_referer) {
                            return 403;
                    }
            }
    }

BTW, do you really use such indentions ?
If yes, then I understand Python author.

No :slight_smile: I have it indented nicely, but some of those were include files,
and I decided to paste the contents of them in so you could see the
entire scope of the server block

what would be the appropriate regex for

if files do NOT match *.css {
gzip off;
}

On Sat, Aug 23, 2008 at 11:54:10PM -0700, mike wrote:

On 8/23/08, Igor S. [email protected] wrote:

css matched by the first location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$

I fixed it - this is what it looks like now. I keep getting the
location ordering confused. That’s probably the most confusing part of
switching to nginx for me is when something matches multiple
locations/etc… anyway, so far so good!

The logic is following:

  1. maximum match for static locations regardless of order,
    it’s very handy: you do not need to think about order;

  2. first match for regex locations, order is important,
    it’s not too handy, but there is no choice: there is no way
    to define maximal match for regex.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs