Speed Up Your Blog Using ZLIB
April 7th, 2008 at 8:50 PM (17 years ago) by Matt FreedmanWith 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.
Find something useful here? Feel free to help me out by sending a donation. :)
7 Responses to “Speed Up Your Blog Using ZLIB”
Leave a Reply
April 10th, 2008 at 8:01 PM | Quote Comment
Matt, I’m loving the new layout. Sorry I couldn’t make it to the magazine launch.
April 23rd, 2008 at 5:18 PM | Quote Comment
Great tip, thanks. I’ve done this and maybe I’m imagining it but it looks like my site loads faster
May 19th, 2008 at 12:14 AM | Quote Comment
[…] 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… […]
May 13th, 2009 at 5:40 AM | Quote Comment
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.
May 13th, 2009 at 4:11 PM | Quote Comment
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.
October 13th, 2009 at 4:21 PM | Quote Comment
This code gave me a 500 Internal Server Error.. Does that mean that zlib isn’t supported either?
October 21st, 2009 at 9:54 PM | Quote Comment
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.