Home » WordPress » WordPress Plugin: GZIP Pages
by
filosofo
on Feb 22, 2008

WordPress Plugin: GZIP Pages

WordPress 2.5 is being released in less than three weeks. While it has a lot of exciting new features, it is also missing a feature that’s been part of WordPress for a while: the option to compress page content for browsers that support compression. Up to version 2.3.3 of WordPress, you could select this option in the admin menu under Options > Reading:

spacer

I’ve found that letting WordPress gzip pages significantly improves performance, typically slashing the size of the text to a fourth. For my home page, that’s a 30% reduction of total page size—including images, ads, etc. A 30% reduction in bandwidth is nothing to sniff at.

So I’ve written a little plugin to restore the gzip compression for WordPress blogs. It’s not necessary if you’re using WordPress 2.3.3 or earlier, but you can go ahead and install it for previous versions in anticipation of upgrading, as it won’t cause any conflicts.

Download

Filosofo GZIP Plugin 1.1 | May 3, 2008

  • filosofo-gzip-compression.zip
  • filosofo-gzip-compression.tar.gz

If you have problems, questions, or suggestions, please leave a comment below or open a ticket in my support forum.

See some of the other WordPress plugins I’ve created.
Like this plugin? Is it worth a latte?

spacer

This month I have received $31.50 in donations for the free plugins I offer here, which is about $0.01 per download.

This entry was written by filosofo, posted on February 22, 2008 at 12:46 pm, filed under WordPress and tagged gzip, plugin. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

38 Comments

  1. Carlo
    wrote on February 23, 2008 at 5:01 am

    I still haven’t tried it but it’s certainly a good idea, though.

  2. _ck_
    wrote on March 1, 2008 at 11:54 am

    You may want to take a look at the two extra tweaks I put into my bb-Gzip plugin for bbPress to add the support for chunked output and setting the gzip compression level to 1 (to use as few cpu cycles as possible) to enhance your plugin. It’s very straightforward.

    bbpress.org/plugins/topic/bb-gzip-webpage-compression

  3. Ryan Williams
    wrote on March 14, 2008 at 10:47 am

    I looked into this a bit further, and it looks like both Apache 1.3 and 2.x have support for gzip out the box, although different methods are used for utilising it with each.

    Seeing as the official WordPress reason for removing the gzip option was so it’s handled by Apache, which is theoretically faster than PHP having to do it, it’s probably preferable to do this. I also noticed that the total file size of WordPress’s pages is smaller when Apache gzip is used rather than the internal WordPress (PHP) gzip method.

    A little Googling will find you Apache 1.3 instructions I’m sure. But for those using Apache 2.x like me, sticking this in a .htaccess in your site’s root should do the trick:

    AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/json application/x-httpd-php application/x-httpd-fastphp application/rss+xml application/atom_xml application/x-httpd-eruby
    Header append Vary Accept-Encoding

    If it doesn’t work, your host needs to install the deflate module (usually enabled by default). Ask them and they should be able to do it.

    That will not only gzip your WordPress pages, but also the CSS, XML, and JavaScript files — none of which are gzipped when the old WordPress function is used.

    You can add any MIME type to the collection above, but do bear in mind that you *don’t* want to be gzipping stuff like images, Flash files, etc, as they’re inherently already compressed; indeed, gzipping these will slow you down. I suggest just sticking to those above.

  4. scoop
    wrote on March 26, 2008 at 1:50 am

    I decided to take WP 2.5 and the GZIP pages plugin for a whirl. The strangest thing happened– as I started to post a comment, my code tab disappeared and the features on the visual tabs are inactive. Needless to say, I ditched both 2.5 and the plugin and returned to the previous version.

  5. inner
    wrote on April 4, 2008 at 8:17 am

    this plugin works nice, but if anyone want also style.css compress can use this tips

    lonewolf-online.net/computers/knowledgebase/php_reduce-wordpress-bandwidth-usage/

  6. Milorad
    wrote on May 2, 2008 at 5:18 pm

    I’d really love to use this plugin as it speeds up delivery of my blog pages by over three times!… however, it also breaks tinyMCE.

    Before 2.5 I never used the visual editor, but it’s much better in the new version of wordpress, so I’d really like to have gzipping enabled, but also have use of tinyMCE.

    Could you look into this please? — Perhaps there’s a way for you to gzip delivery of the blog, but not wp-admin?

    Cheers, and thanks for contributing plugins to the wordpress community.

  7. filosofo
    wrote on May 3, 2008 at 8:28 am

    Thanks for pointing that out Milorad. I’ve updated the plugin in version 1.1 to work with TinyMCE. This should solve scoop’s problem as well.

  8. Milorad
    wrote on May 3, 2008 at 2:06 pm

    Many thanks! that has to be the fastest response to a problem report I’ve ever seen or heard of.

    Nice work spacer

  9. Gustavo Leig
    wrote on May 23, 2008 at 7:23 pm

    Is this compatible with wp-cache? What do I need to do to make it work together?

  10. filosofo
    wrote on May 24, 2008 at 8:25 pm

    I don’t know about WP-Cache, but WP-Super Cache has Gzip functionality built in, so you don’t need to use this plugin if you use it.

  11. aphex3k
    wrote on July 30, 2008 at 8:42 am

    Im using WP 2.6 and activated your plugin. How to validate it works or where to active the function?

  12. filosofo
    wrote on July 30, 2008 at 2:46 pm

    If you’re using Firefox, you can right-click your blog’s page, select “View Page Info,” and then under “header” see if there is a “Accept-Encoding: gzip,deflate” line.

  13. JP
    wrote on December 6, 2008 at 11:26 pm

    I installed and activated this plugin, but there’s no additional headers added. “View Page Info” doesn’t show anything. I added the following to my header.php manually:

    <meta http-equiv=”Content-Encoding” content=”gzip” />
    <meta http-equiv=”Accept-Encoding” content=”gzip, deflate” />

    What does the plugin do that’s different? Did I do something wrong with the plugin?

  14. filosofo
    wrote on December 6, 2008 at 11:48 pm

    “View Page Info” doesn’t seem to show the response headers anymore when using Firefox 3, but I know they’re there from other tools, so I think it’s “View Page Info” that has changed.

    Adding the http-equiv meta tags probably doesn’t do anything.

  15. JP
    wrote on December 7, 2008 at 2:03 pm

    Any idea for what tool I can use to view the updated headers?

  16. filosofo
    wrote on December 7, 2008 at 7:09 pm

    Try the Firefox “Web Developer” extension.

  17. Kingsley Tagbo - IT
    wrote on December 22, 2008 at 11:18 am

    Does it work with WordPress 2.7 … it seems to work with FireFox but not with IE7 on Vista

  18. Eric Lamb
    wrote on March 23, 2009 at 12:05 pm

    I have the same issue as Kingsley Tagbo; it doesn’t work with IE on Vista.

    I have to tell you man, that SUCKED to find out. I, stupidly, didn’t test that it worked in IE because it worked in FF3.

    I just needed a quick fix so I added the below to the plugin around line 24:


    if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 7.0; Windows NT 6.0') !== FALSE){
    return FALSE;
    }

    All it does is not compress for IE7 if it’s coming from a Vista machine. Not a long term solution but since most of my visitors use FF or Chrome it’s ok with me not to gzip for IE7.

  19. Eric Lamb
    wrote on March 23, 2009 at 1:43 pm

    Well, I did some research on the issue and it looks like IE7 just doesn’t like gzip AT ALL. Weirdest. Thing. Ever.

    Do a google for “gzip IE7″ (without quotes). There are all sorts of stories about how IE7 doesn’t work with gzip. Pity…

    It looks like the fix provided above is the long term solution. That really, REALLY, sucks.

  20. Glenv
    wrote on April 30, 2009 at 12:57 am

    Does it work for IE8?

  21. SEO Tips
    wrote on October 26, 2009 at 9:39 pm

    Does it help much to improve website load time ?

  22. Liam
    wrote on November 9, 2009 at 6:51 pm

    Thank you so much for creating this plug in! I’ve been searching around for the best way to implement G-Zipping on my blog as it’s fairly image and DNS request heavy but I wasn’t having much luck.
    You’ve saved the day, and my bounce rate!

  23. trecords
    wrote on December 8, 2009 at 2:52 pm

    That is great plugin,Thank you very much.
    Do this plugin works with wp 2.8 ?

    Thank you.

  24. hiroshi
    wrote on January 1, 2010 at 12:46 am

    Its cool but we have WPsuperCache for this purpose. Isn’t it?

  25. filosofo
    wrote on January 1, 2010 at 11:28 am


    Its cool but we have WPsuperCache for this purpose. Isn’t it?

    You’re correct: WP-Super-Cache includes this feature, so if you’re using it you don’t need this plugin.

  26. HD
    wrote on March 20, 2010 at 5:56 am

    Thank you. I am going to try it

  27. מאמרים
    wrote on March 31, 2010 at 3:11 am

    brilliant!

    now with google page speed, this is a must

  28. jan wrote on May 26, 2010 at 3:41 am

    it’s maybe not possible due to file-permissions, but could this plugin also compress .js + .css files used by various plugins

  29. lucas
    wrote on May 27, 2010 at 11:57 pm

    I think this is what I’ve been looking for…. I’m looking to improve the page speed of my wp blog – googles webmaster tools suggested I “gzip and cash static items”

    Please let me know that I’m on the right track and please point me to a step by step tutorial to install and run this program. Assume I know nothing, because I have no idea what I’m doing spacer

    Thank you!!!

  30. Lucas
    wrote on May 28, 2010 at 10:27 am

    How can I test to see if the plugin has worked?

  31. Magnus Lander
    wrote on December 19, 2010 at 8:09 am

    You can test the functionality of mod_gzip at www.whatsmyip.org/http_compression/