Matt's Blog

Speed Up Your Blog Using ZLIB

April 7th, 2008 at 8:50 PM (17 years ago) by Matt Freedman

With the release of WordPress 2.5, there is no longer an option to enable GZIP compression. This option was axed for the reason that it’s better to enable compression on the server, rather than through WordPress. GZIP is basically a compression “tool” that compresses files before sending them to the browser, if the browser states that it can handle GZIP compression. All modern browsers support GZIP compression, and send the appropriate header to the server to tell it that it can handle compression.

However, there is another compression library that is generally preferred over GZIP, called ZLIB. It’s essentially the same as GZIP, and is initiated by the same gzip header that browsers send.

We’ll be using ZLIB to speed up your blog. We’re using ZLIB because using GZIP causing TinyMCE (in WordPress) to be double compressed, and to stop working properly, using ZLIB works around the issue. Also, since ZLIB is preferred, we might as well use it.

Before enabling ZLIB compression, you’ll want to check with your host to ensure that PHP has been compiled with ZLIB support. I can confirm that BlueFur has it enabled on most (if not all) of their servers.

Now that you’ve made sure that your host can support ZLIB compression, let’s actually enable it. First of all, open your blog’s root .htaccess file. Then, you’ll want to add the following line to the file, above the WordPress code (# BEGIN WordPress):

php_flag zlib.output_compression On

Save the file, and reupload it. You should now notice improved speed in the execution time of your blog. On my blog, page execution has, on average, been reduced by 50%. However, your results may vary.

It’s important to note that, if you’re currently using any other compression or caching systems, you cannot use this in conjunction with them; you’ll have to choose between them or ZLIB compression.

This compression method will also work on any fairly dynamic site, it’s not limited to blogs.

7 Responses to “Speed Up Your Blog Using ZLIB”

  1. Mark Dunn
    Mark Dunn says:

    Matt, I’m loving the new layout. Sorry I couldn’t make it to the magazine launch.

  2. Joel Williams
    Joel Williams says:

    Great tip, thanks. I’ve done this and maybe I’m imagining it but it looks like my site loads faster :)

  3. Wordpress 2.5 Removes GZIP Option :: User First Web
    Wordpress 2.5 Removes GZIP Option :: User First Web says:

    […] WordPress 2.5 no longer provides an option to turn on gzip compression. According to Matt Freedman, the “option was axed for the reason that it’s better to enable compression on the server, rather than t… […]

  4. Harkin Banks
    Harkin Banks says:

    I’m using zlib and phpinfo() shows that it’s installed. But, I would like to confirm that it’s actually working and I don’t know how to do this. Any suggestions? Thank you.

  5. Matt Freedman
    Matt Freedman says:

    When ZLIB is enabled, gzip will appear under Content-encoding: in the server’s HTTP header response for PHP files. You can use this tool to view the HTTP response for your site.

  6. Brad Ney
    Brad Ney says:

    This code gave me a 500 Internal Server Error.. Does that mean that zlib isn’t supported either?

  7. Matt Freedman
    Matt Freedman says:

    Brad: yes, that is one possibility. It’s also possible that you’re not permitted to override those settings. Contact your host, they’ll be able to determine why.

Leave a Reply

Quote selected text

Leave the following field empty: