Forum: NGINX What gzip_types are recommended?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4ead4b1fb084dbd176b0feaf2fca5c67?d=identicon&s=25 KT Walrus (Guest)
on 2008-12-09 22:52
(Received via mailing list)
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
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 mike (Guest)
on 2008-12-10 00:45
(Received via mailing list)
On Tue, Dec 9, 2008 at 1:40 PM, KT Walrus <kevin@my.walr.us> 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
4ead4b1fb084dbd176b0feaf2fca5c67?d=identicon&s=25 KT Walrus (Guest)
on 2008-12-10 06:03
(Received via mailing list)
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
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 mike (Guest)
on 2008-12-10 06:24
(Received via mailing list)
why would you add a header that is already sent by default?
4ead4b1fb084dbd176b0feaf2fca5c67?d=identicon&s=25 KT Walrus (Guest)
on 2008-12-10 07:53
(Received via mailing list)
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.
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 mike (Guest)
on 2008-12-10 08:01
(Received via mailing list)
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..
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2008-12-10 08:19
(Received via mailing list)
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.
This topic is locked and can not be replied to.