Improve Site Performance with GZIP

By John Kim | January 15th, 2010    Retweet  

One of the biggest killers of a website is slow performance. A few years ago, the rule was to have your website load no longer than 13 seconds on a 56k modem. In the age of high speed internet, your site shouldn’t take longer than 5 seconds to load up. This magic number derives from the bounce rate of internet users based on load time, and with such strict guidelines, I find it amazing that most developers place performance last on their priority list. Although there are tons of tips and tricks to use while optimizing a website, a really easy one is to add gzip to your web server.

Enable Gzip on httpd.conf
If you are using an Apache server, you can enable the gzip module into your httpd.conf file. Usually this module is commented out, but you should find a code that looks like this in the httpd.conf

#LoadModule deflate_module modules/mod_deflate.so

To enable this just remove the ‘#’ in front of the line.

Next you can scroll to the bottom of your httpd.conf, add about 6 new lines just to keep your code clean and copy and paste the code below.

#MOD_DEFLATE
<IfModule deflate_module>
SetOutputFilter DEFLATE
SetInputFilter DEFLATE
#the two above compress everything unless excluded below
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .avi$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .mov$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .mp3$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .mp4$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .rm$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .plist$ no-gzip dont-vary
# Below is an example where you get rid of what’s above and you explicity compress
AddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphp application/x-httpd-eruby text/html
DeflateFilterNote ratio
DeflateCompressionLevel 9
</IfModule>

That is your deflate configurations, and it basically tells the server to compress every file except for images, documents, and other non web based files. Once you are done configuring your server, just restart Apache and now you have gzip enabled.

This little web developer secret should greatly improve the performance of your site. And for those wanna be developers who don’t know this, well clean up your act, because you’re making us real developers look like fools. Guilty by association.

digg it reddit stumble it facebook
Post to MySpace!
Add this to your blog:
(Copy & paste code)

Leave a Reply

Copyright © 2013 . All Rights Reserved . iCurious Media
Terms and Conditions . Privacy Policy . Site Map