Browsers are equipped to serve compressed pages. Most hosts too have mod_gzip or zlib extensions installed to ensure you can avail of these features.

Compression ensures that your browser receives a smaller packet and so you effectively save bandwidth.

WordPress by default also comes with this feature that enables you to compress the webpages and send them to the browser.

You can find it under Options » Reading. Scroll to the bottom where you will find WordPress should compress articles (gzip) if browsers ask for them.

I’ve noticed upto 1 second difference between the loading times of my pages with this checked and unchecked.

After checking this, it is best to analyze your page to see if gzip is infact working or not. For this I use Web Page Analyzer.

In case you do have the above option checked and this is reporting that the files are not compressed, you will need to talk to your host.

Many of us have WP-Cache installed on our WordPress installation. When a page is requested for the first time, WP-Cache creates a cache file for the page. Subsequent requests are served from the cache. This ensures that the page doesn’t need to be recompiled, thus reducing the load on the server.

The problem with WP-Cache is that it doesn’t support GZip encoding. This means, that you need to first uncheck the above option that I talked about. This also means that you’re increasing the load time of your pages as well as consuming more bandwidth.

However, Mark Jaquith and Chris Stormer have found that a minor change in the the code of the plugin can turn on GZip encoding.

All you need to do is find the line

  1. foreach ($meta->headers as $header) {

in wp-cache-phase1.php. This is line 35 in my file.

Just before this line you need to add:

  1. if ( extension_loaded(‘zlib’) ) ob_start(‘ob_gzhandler’);

Now, your file will look like:

  1. if ( extension_loaded(‘zlib’) ) ob_start(‘ob_gzhandler’);
  2. foreach ($meta->headers as $header) {

Save the file and upload it and your set.

You can analyze the page again using the analyzer to check if the files are compressed.

Note that the above option in WordPress has to be disabled, or your pages will be royally messed up!

For those interested, the line of code we added checks if the zlib extension is installed. If it is, then it calls ob_gzhandler which gzips the output buffer and sends it to the browser.

Subscribe to the Feed
Liked this article? Stay in touch with us! Don't forget to Stumble It!
Grab the site feed or add to your Technorati favs.


Post Details

Post Date :
Monday, Mar 12th, 2007 at 2:49 pm
Category :
Plugins and Tips & Tricks and WordPress
Tags :
, , , , , , ,
Do More :
Both comments and pings are currently closed.

Related Posts

Some posts related to the post you have just read:

Search this site for Related Posts

Google