Compressing php output with wp-cache2 WordPress Plugin

By Angsuman Chakraborty, Gaea News Network
Sunday, September 18, 2005

Wp-Cache2 is a WordPress Plugin to cache WordPress generated pages. However it doesn’t work with in-built gzip compression. Lets see how we can solve it.

Wp-Cache 2 significantly increases performance of WordPress enabled websites. Additionally it drastically reduces the processing load on the machine. It is intelligent to understand when to refresh the cache based on author / publisher activity.

This blog uses wp-cache 2.

It comes with some costs. It doesn’t allow you to compress your output in gzip format, a facility provided by WordPress.

BTW: wp-cache-2 doesn’t work on Windows based servers.

The solution is to use Apache mod_deflate module.

A simple configuration (add in httpd.conf) might be:

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php

This assumes you have mod_deflate loaded. If not load it first:

LoadModule deflate_module modules/mod_deflate.so

Let me know your experience with this.

Discussion
May 25, 2009: 1:18 pm

I’ve had to turn WP-cache2 off temporarily anyway, because v2.20 isn’t refreshing when new comments or posts are bad

January 6, 2007: 8:55 am

mod_deflate is a module specific to the Apache 2.0 series, so I can’t install it as it’s not compatible with cpanel yet :-(.

I’ve had to turn WP-cache2 off temporarily anyway, because v2.20 isn’t refreshing when new comments or posts are bad

January 5, 2007: 8:56 pm

Yes and it is faster too.

January 5, 2007: 9:34 am

When using mod_deflate do I get the benefits of mod_gzip, i.e. saved bandwidth?

October 22, 2006: 8:14 am

[...] Compressing php output with wp-cache2 WordPress Plugin [...]

January 31, 2006: 6:00 am

It seems to me that the problem was that with WP’s gzip turned on, it was caching the zipped output. I edited wp-cache-phase1.php and put in the following:

if( extension_loaded('zlib') ) ob_start('ob_gzhandler');

right above this line:

foreach ($meta-»headers as $header) {

And it seems to work beautifully. That caches the plaintext, but gzips the text before delivering on cached hits. Might work for people you can’t mess with server configuration files.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :