PHP Caching with APC and WP-Cache
Greg Szorc recently pointed me to this excellent PHP optimization tutorial presented at OSCON 2006 by Rasmus Lerdorf. In the tutorial, he shows how to build a website with some basic SQL calls that handles over 1100 requests/sec using optimization techniques. One of the optimizations he uses is an opcode cacher for PHP called APC. In gentoo, to get this optimization working required a simple emerge dev-php5/pecl-apc. Mr. Lerdorf then goes on to use http_load and callgrind to demonstrate the performance of the website and isolate problem sections.
The performance this PHP cacher provides is by far the best I have seen. I enabled it on this site and the pages are loading lightning fast. I did run into some problems. WP-Cache, an excellent page output caching module for WordPress, and APC don’t play well together. They caused a “White Page of Death” - that is, the first time I loaded a webpage, the page returns blank. Subsequent requests return the desired page, but this is hardly ideal.
Mark Jaquith documented this “white page of death” problem that occurs between the interaction of APC and WP-Cache. His solution, to filter out apc caching wp-cache’d pages, has not seemed to work for me yet. As of right now, I have disabled wp-cache because the performance benefits of APC outweighed those of WP-Cache.
Hopefully, one day, these two excellent solutions will live in harmony. I will continue to try to get them to co-exist as Mr. Jaquith has done. Currently, I have tried setting apc.filters=”-.*cache.*\.php” and apc.filters=”wp-cache-config”. I have tried every possible permutation of flushing the cache and restarting apache. No luck yet.
The reason you get the white page is that errors are suppressed in the WP-Cache2 plugin (although you could also suppress them in php.ini). What you can do is remove all those silencing “@” symbols, and see what error is killing you… that might help you find out a solution. The other thing to do is to make sure that your php.ini settings for apc.filters are actually being followed.