Compress all the css, js, html files with GZIP

by Geethalakshmi 2012-06-15 15:26:12

Compress all the css, js, html files with GZIP


Add following snippet into your htaccess file and compress all the css, js, html files with GZip compression.

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>


Above code works only if mod_gzip module is enabled in your webserver. You may want to add following snippet if your webserver provides mod_deflate support.

<Location>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI
.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI
.(?:exe|t?gz|zip|gz2|sit|rar)$ no-gzip dont-vary
</Location>


If your webserver does not support mod_deflate then you may want to use following snippet.

<FilesMatch ".(txt|html|htm|php)">
php_value output_handler ob_gzhandler
</FilesMatch>
641
like
0
dislike
0
mail
flag

You must LOGIN to add comments