How to make your blog faster by compressing it

I’ve talked before about how important it is for a blog to load quickly, not only for the reader but also for the search engines and their rankings.

One easy way to speed up the loading time is to use something “gzip Compression”.

Most people are familiar with “zipping” files, this basically just compresses the data so that it takes up less space on a hard disk.  The same is true of data from your web server in that it can be compressed and then “unzipped” by the browser on the readers’ computers.

Activating it is really easy:

METHOD ONE: Use a plug-in

There is a simple plug-in for WordPress that activates gzip compression, and it’s called “WordPress GZip Compression“.

Once installed and activated there are no settings to worry about, it just makes your blog faster!

METHOD TWO: Manually with PHP

If you prefer not to use a plug-in, then you can edit your theme to activate gzip compression.

Open the header.php file and add the following code to the very beginning, ie. on the very first line before the DOCTYPE call:

<?php if (substr_count($_SERVER[‘HTTP_ACCEPT_ENCODING’], ‘gzip’)) ob_start(“ob_gzhandler”); else ob_start(); ?>

It’s that simple!

Two words of warning.  Not all web servers and hosting providers support gzip so backup up your blog first and try it out once you’ve activated it.  Clear your browser cache first!

And older browsers do not support it either, so if you still have a large number of visitors using Internet Explorer 6, then you might decide it’s better not to activate gzip for now.

About Graham Tappenden

Graham Tappenden is a blogger from Germany. He has written code for WordPress themes since 2006 and been creating websites since 1994.
This entry was posted in Other Technical Stuff, Plug-ins and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *