What gzip_types are recommended?


#1

What gzip_types are safe to compress with most browsers? Can
javascript and css be safely compressed?

http://wiki.codemongers.com/NginxHttpGzipModule#gzip_types

Might be nice to update the link above with the answer.

Also, can I make sure that Javascript and CSS files are cached for the
user and can I set an Expires: time for these file types?

Thanks. I’m new to nginx and I am trying it out to see how much it
helps with performance for a PHP coded forum site.

Kevin


#2

On Tue, Dec 9, 2008 at 1:40 PM, KT Walrus removed_email_address@domain.invalid wrote:

What gzip_types are safe to compress with most browsers? Can javascript
and css be safely compressed?

I have this
gzip_types text/plain text/css application/x-javascript text/xml
application/xml application/xml+rss text/javascript;

seems to work well. Never had any complaints.

http://wiki.codemongers.com/NginxHttpGzipModule#gzip_types

Might be nice to update the link above with the answer.

Also, can I make sure that Javascript and CSS files are cached for the user
and can I set an Expires: time for these file types?

Yes

location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ {
expires max;
}

Thanks. I’m new to nginx and I am trying it out to see how much it helps
with performance for a PHP coded forum site.

http://getfirebug.com + yslow! for firefox. makes determining this stuff
easy


#3

Thanks.

Is there a delete_header or replace_header directive?

I’m trying to specify the character encoding for my css file, and this
results in two Content-Type headers:

HTTP/1.1 200 OK
Server: nginx/0.6.34
Date: Wed, 10 Dec 2008 04:43:16 GMT
Content-Type: text/css
Content-Length: 12577
Last-Modified: Wed, 10 Dec 2008 02:39:22 GMT
Connection: keep-alive
Cache-Control: max-age=86400, must-revalidate
Content-Type: text/css; charset=iso-8859-1
Accept-Ranges: bytes

I suppose this is a mostly pointless thing to do, but I’m trying to
learn how nginx works with headers.

I expected that when I did “add_header Content-Type” that it would
have the option of replacing any existing header.

Kevin


#4

why would you add a header that is already sent by default?


#5

I was just thinking that it might be good to say what charset the .css
uses rather than relying on the browser to default to the correct
encoding.

As I said, I’m just trying to learn and this particular example of
replacing a header might not be the best, but I would like to
understand how to replace headers.


#6

You can add additional headers but the proper headers for normal HTTP
behavior will be sent automatically by nginx. You only need to add
different headers that aren’t already included. Or you can push
headers through using a server-side language like PHP too…


#7

On Tue, Dec 09, 2008 at 11:50:23PM -0500, KT Walrus wrote:

Content-Type: text/css
I expected that when I did “add_header Content-Type” that it would
have the option of replacing any existing header.

You may set charset using

    charset  iso-8859-1;

There is no delete_header or replace_header. You may delete a header
using

    add_header  NAME  "";

but it does not works with any headers.