Not signed in (Sign In)
    • CommentAuthormick
    • CommentTimeMay 26th 2008
     permalink

    Hi,
    I’ve been trying for the last couple of hours to get nginx to gzip compress javascript files being returned from mongrel.

    The files have mime type application/x-javascript.

    Below is a snippet from my nginx config:

    gzip  on;
    gzip_http_version 1.0;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    # make sure gzip does not lose large gzipped js or css files
    # see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
    gzip_buffers 16 8k;
    

    I’d really appreciate any pointers. I’ve searched the web for answers to no avail.

    thanks,
    mick

    • CommentAuthormick
    • CommentTimeMay 26th 2008
     permalink
    BTW: I'm having the same problem with other types of files (e.g. css ) as well.
    • CommentAuthormick
    • CommentTimeMay 26th 2008
     permalink
    I believe I've narrowed it down to the fact that files which are not being gzipped have the following in their header:

    Accept-Ranges: bytes

    It makes sense that such files are not gzipped since that would make range based access difficult/impossible.

    I think I now just need to work out why Accept-Ranges is set for some, but not all, files. Any hints?

    thanks,
    mick
    • CommentAuthormick
    • CommentTimeMay 26th 2008
     permalink
    Problem Solved:

    Turned out it was the browser caching things that was mucking me around. I had earlier gotten expiries working, and then went on to get gzip working. The files were not appearing to be gzipped as they were already cached by the browser (due to the expiries). When I manually cleared the browser cache, the files came down gzipped. Oops!

    Maybe I should use curl rather than a browser for such work in the future ...

    thanks for listening,
    mick
    Thankful People: railsninja
    • CommentAuthorrailsninja
    • CommentTimeMay 11th 2009
     permalink
    Thanks for posting the reason, that exact same thing was just tripping me up and prompted me to do a hard refresh on the server I was just setting up and BHAM, all was well. Thanks.