Thursday, September 20, 2007

Using GZIP compression in web servers using .HTACCESS

I use PHP CodeIgniter support for GZIP compression but I had to do some changes in a CI library for to compress javascript libraries but thanks to Joan Piedra and his post in jQuery Mail list I see this solution better:

in the .htaccess:

<ifmodule mod_headers.c>

<ifmodule mod_deflate.c>


# Compress some text file types

AddOutputFilterByType DEFLATE text/html text/css text/xml application/x-javascript



# Deactivate compression for buggy browsers

BrowserMatch ^Mozilla/4 gzip-only-text/html

BrowserMatch ^Mozilla/4\.0[678] no-gzip

BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

</ifmodule>

</ifmodule>



NOTE: It doesn't work with Apache version < 2 web servers. You need deflate and headers module.

1 comments:

NEO_JP said...

Hola Jose, me alegro que te haya servido el pequeño truco del htaccess + mod_deflate.

Gracias por el credito, un saludo.