Save your bandwidth and your visitors' time!

How can you reduce bandwidth consumed by your website by about 30% and considerably speed it up in about 5 minutes?

mod_deflate is a great apache2 module which provides on the fly compression of your website contents. If you have deployed your webserver in the past four years chances are your are already using it. However, mod_deflate by default will only compress your text/html, text/plain and text/xml.

While it's a good idea to whitelist the type of files that are compressed (no reason to attempt to decompress a file that is already compressed, such as image files, zips, etc), we are leaving out some important files we should compress too.

With the virus-like spread of scriptaculous, jQuery and a wide set of javascript tools, and the rather complex css files we are using nowadays it makes a lot of sense adding compression support for those types of files.

And its such an easy feat too! Just add the following to your webserver configuration:

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/javascript text/css

And restart with

[ -e /etc/init.d/httpd ] && /etc/init.d/httpd restart
[ -e /etc/init.d/apache2 ] && /etc/init.d/apache2 restart

and that's it! All your website's files are now being transmitted using compression.

Want to see how much you gained from this? Add the following to your configuration and see the compression ratio achieved.

DeflateFilterNote Input input_info
DeflateFilterNote Output output_info
DeflateFilterNote Ratio ratio_info
LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
CustomLog /var/log/apache2/deflate_log deflate

And have a look at the /var/log/apache2/deflate_log file to see the compression rate.

Trade off

So what is the trade of of doing this? Just a little CPU time, you might want to check your system load to make sure your system's bottleneck is not the CPU before doing this.

Enjoy!

Comments
Rhonda, October 02, 2009 22:35

I am a blogger and thinking of building my own website.I do have little knowledge of these things.Reading your blog again and again to understand these things.Thanks for tips.:)

Anbuinfosys, October 03, 2009 01:53

I am a now very clear about reducing the time to load my web page.I understand here something about saving the time of the visitor to make them interested with My site.Thanks for the Reference.It is really interesting to read your future posts.

Robert McNatt, October 03, 2009 10:53

Hey thanks for the tip! I was actually having trouble with this exact issue. You solved it! I'll be back to read more of your posts. Excellent information.

Write comment
Name:
Email: