Enable Gzip Compression

One of the things that Page Speed recommended was to Enable Gzip Compression.   I’m not going to go into all the ways I tried to implement this (and blew up the site in the process.   I’m going to cut to the chase and show you the steps it took to get this in place and working.

This is part of what I meant when I said get your geeks speak dictionary out.   In order to Gzip your site you need to have the zlib activated on your site. You do this in the php.ini file.   Or in some hosts (GoDaddy) it will have to be php5.ini, if you are running PHP5

Create PHP info

This step is necessary so you can see what the php setup is on your site and verify that the changes you make are in place.

Open Notepad and paste this:


Name the file phpinfo.php   and FTP it up to the root of your blog.

Go to your site in a browser and at the end of the url add /phpinfo.php   This will show you a lot of information, you will see zlib somewhere in there.


This is after activation

Modifiy the PHP.ini file

Add this to the php.ini   or php5.ini file that is in the root of your hosting directory

zlib.output_buffering = On
zlib.output_handler = ob_gzhandler
zlib.output_compression = Off

If the blog is in the root directory that is where the php.ini file should be located.   If it is in another directory under the root hosting directory you will need to add this code to the root directory php.ini file.

Modify your Theme Header

Add this code in the header of your theme “ABOVE THE FIRST LINE”

<?php ob_start(“ob_gzhandler”); ?>

Once this is in place:

  1. Open your site in a firefox
  2. Open Firebug
  3. Run Page Speed Analyze
  4. You should no longer see a RED enable gzip compression

This should help reduce your page load time.

But remember what I said in the first post.   If you have a caching plugin installed, you will need to deactivate it, clear the cache, make these changes and then activate the cache plugin again.

Next we will take a look at changing some of your generic php code in your theme to specific HTML.   This will reduce the number of database queries and help your page load speed.


  1. Thanks for this. I just got the Page Speed plugin last week and saw that Google recommends Gzip but I had no idea what it is or how to do it. How much load-time does this really save? I guess any time saved, even a fraction of a second, is better than not. But if it’s such a useful thing to do, I wonder why it’s not built into WordPress by default…
    .-= Josh´s last blog ..Calgary Movers =-.

  2. Josh,

    Gzip is server side application. It can’t be built into WP.


  3. Hi Dave,

    Would Gzip speed up the page load time for my 246 blogs I have on two WordPress MU sites on a dedicated server? One of the things I’ve done to speed up page load time is to install WP Super Cache. It seems to work well. The two blogs I’m most interested in working very fast are:

    Indianapolis News, Events, Information, Photos and Videos
    Indianapolis Real Estate and Indianapolis Homes For Sale

    Any other advice or articles you’ve done about speeding up a blog?

  4. If you are using super cache I wouldn’t bother with gzip. But it wouldn’t hurt. I personally don’t like super cache or any of the caching programs I’ve tried. To often they interfere with changes made. Like new plugins or theme tweaks. Especially when you are trying to work on the site and see the changes. So I stay away from cache plugins.


  5. Dave, thanks for the fast response. I have had the trouble you’ve talked about when I make changes. I have to delete the cache files before I can see the changes, at times.

  6. I’ve tried this, but I don’t have a php.ini or php5.ini file in my root directory.
    .-= Bill Bennett´s last blog ..Writing tips: “If it sounds like writing, rewrite it” =-.

  7. Bill,

    Where is your site hosted? Did you check to see if Gzip was already enabled? Some hosts are doing that automatically now. (Bluehost being one) so you don’t have to turn it on.


  8. Hi,

    I just run Page speed on thi page and it gives only 63% and propose to enable compression for the page 🙂

  9. Alexei,

    I thing you might want to check that again, there is a green check mark next to enable compression which means it is enabled.

    The other things they recommend which brings the score down, are really unnecessary and not advised for dynamic pages or those who don’t have their own server (which is the majority of us)


  10. Yeah, you are right. BTW, one thing that might really improve the score of the page and speed is combining external JavaScripts. i did it on my Drupal sites and speed difference was dramatic.

  11. Alexei,

    Unfortunately, those scripts aren’t ones we have control over, they are handled by plugins on the blog. Combining them doesn’t seem to be possible.


  12. I use Drupal for my site malinamusic.ru and I though the same way till I found one checkbox in Drupal Performance configuration. And it combined all external Javascripts of all external modules I use automatuically for me. I suggest you to look for you platform settings. It might have it. I guess you use wordpress?

  13. After reading this I realized the problem that I was having all along was zlib wasn’t activated on my site. The people at godaddy should of explained to me that I had to activate it in order gzip my site.

  14. They pretty much don’t explain anything which is why I never call them and figure it out myself, then write posts like this one.


  15. Ok this is something i can’t fix on blogspot then. Im out of ideas how to reduce the page load timed of my blog other than removing pics. I don’t understand why google counts all posts on my homepage as a part of it as a whole even though i have “read more” links after only few sentences for each post. I mean, lets say i have 10 previews of actual posts (with just one picture for each post) on my homepage and “read more” for every of those posts. And, all of those posts have their own separate pages. So why would all those posts count as a part of homepage like they are completely there and not just their previews. Sorry for bad english, but i hope you understood the question. Tnx

  16. Selina,

    The page load time in only based on what content is on the page. What is slowing down your site are all the widget, chicklets, and slideshow on your home page. Those are a real drag on page load.


  17. I can’t get gzip to work on my drupal pages.

    If I put the code on a regular php page uploaded to the root it works.

    However, for some reason, it doesn’t work for drupal – with GoDaddy.

    Any ideas?

  18. Matt,

    I’ve never worked with Drupal. Wish I could be more help.


  19. At long last! I have been looking for a dummy guide for gzip compression – couldn’t get my head around the instructions on googles help pages, but will give it a go with your instructions, ty 🙂