From The Blog

gzip compression using .htaccess

28 January 2013, in Application ServersSEO

You can compress static files such as image files (.jpg, .png, ....), Flash files (.swf), Style sheets (.css), Javascript (.js)

to reduce size of fetched files and make pages load faster.

You can do gzip compression on these files via .htaccess file


# 480 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"

# 2 DAYS
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"

<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"

<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.*


Post a Comment