Speed Up WordPress Without Using A Cache Plugin

Today I decided to try something different with this blog. I decided to remove the WP Super Cache plugin and just try server compression instead.  And so far I am very pleased with the results.

I tend to use the caching plugin on any WordPress site I set up.  I don’t always do this because the blog has a lot of traffic and needs it; I do it just so the blog’s responsiveness is as quick as possible.  After today though I’m totally rethinking that strategy.

If you read the post about 5 Quick Tweaks To Improve Your WordPress Blog, you might remember me mentioning using zlib compression to boost your page loading speed.  I tried it in the past, but it didn’t really work for me.  Today I can admit (with a little bit of embarrassment) that it didn’t work back then because I didn’t set it up right.

For zlib compression to work, you have to have the PHP configured correctly on your server.  How you get this to work may vary depending on what type of server or hosting you have, but I will tell you the steps I took to get it to work on my server.

First of all, I’m hosting on Hostgator and I’m using a CentOS server.  If you are using a hosting provider that is using a Linux server and has Cpanel, then the steps I took just may be the ones you would have to take to accomplish this as well.

After logging into my Cpanel, I scrolled down to the “Software/Services” section and clicked on the php.ini settings

At the top of the page of the php.ini QuickConfig page, the zlib compression option is quickly visible.  Mine was set to “Off”, so I just checked the radio button for “On” instead and then saved my settings.

After doing this, I added the following little piece of code to thevery  top of my header.php file, above the doctype html tag in my WordPress theme folder:

<?php
ini_set('zlib.output_compression', 'On');
ini_set('zlib.output_compression_level', '1');
?>

And that is all that it takes!  I did deactivate the WP-Super-Cache plugin and then deleted the files from my site and I think that this site is running just as fast, if not faster, than it did with just the caching enabled.

I even tested this site here to see what kind of gains I’ve made by enabling zlib compression.  According to them, this blog runs nearly 4 times faster than it did without compression.

So if your blog isn’t getting hammered by Digg or Stumbleupon every day, and you want to keep the amount of plugins you use to a minimum, I would recommend you implement some form of compression over a caching plugin.

No related posts.

{ 2 comments… read them below or add one }

Harjeet Singh February 28, 2012 at 6:39 pm

Hello Rob,

That was a good tweak. It works fine but the images are not showing anymore, although the code seems to be fine. Can you have a look at my blog. I will be trying to debug it, but if you can help before i find it. that will be great.

Reply

Harjeet Singh February 28, 2012 at 6:47 pm

hey , just did google and found that testing the value for “zlib.output_compression_level” can help as it varies from server to server specification. For me the Value 2 worked fine . You are awesome man. Will be using this on my other blogs too.

Reply

Leave a Comment

Previous post:

Next post: