If you can use htaccess on your server and want to use gzip for faster Page Load Times / Bandwidth Saver. You can put the following lines in the htaccess file on your server:
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl|jpg|png|gif)$
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>
This basically checks to see if mod_czip.c is found and if it is it will compress the files for you so they are faster to send to the browser. This supposedly speeds it up 35-40%. Then file sized supposedly go down 55-65%.



Pingback: samaxes » .htaccess - gzip and cache your site for faster loading and bandwidth saving
Pingback: .htaccess - gzip and cache your site for faster loading and bandwidth saving - samaxes
Hey thanks but wondering if my host provider does not support this module?
Thank you for this fantastic post :)
Thanks for this!
I am going to try this now.
So in other words, If I have gzip uploaded to my server, I don’t have to do anything else besides add this to my .htaccess file?
“This basically checks to see if mod_czip.c is found”
How do I go about making sure that mod_czip.c is found on my server? I download Gzip and uploaded, but I do not see mod_czip.c included in the file anywhere.
Great. Thanks. Using both of YSlow and Google page speed makes your posting valueable for me.
Gzip is great for compressing files but don’t think that it’ll always be the best option for you. Gzip adds processing overhead to the server, specially since these pages aren’t cached and are gzipped on the fly. As bandwidth gets cheaper, it really doesn’t make sense to sacrifice precious server processing time on gzipping. I would recommend caching gzipped pages and using the htaccess to serve those if they exist in a directory (such as /cache )
Thanks for the code. But my shared host (hostgator) doesn’t support this module. please help me.
Pingback: .htaccess – gzip and cache your site for faster loading and bandwidth saving | Ubuntu Viet
If youry provider doesn’t have this module enabled, you can add the following line instead:
php_value output_handler ob_gzhandler
………….this makes PHP to compress your PHP files.
Thanks for sharing the code. Hope my hosting provider supports this… will check asap.