Adventures with WP-Cache2 & APC
Update 3: see update 2 for the solution!
APC (Alternative PHP Cache) is great for WordPress. It caches the compiled WordPress PHP files and greatly speeds up subsequent loads. I even wrote a WordPress plugin to make WordPress store its objects in APC instead of in the default file-based object cache.
WP-Cache2 is also great for WordPress, because it caches the HTML output of WordPress for a specified period.
So if both are good, together they should be awesome, right? Well… in theory, yes. Unfortunately, I’ve been having a heck of a time getting them to play together. What would happen was that pages would start showing up blank. Just a white page. Real helpful. The same thing happened when you tried to access /wp-admin/ The only way to fix it was to delete WP-Cache2. In desperation, I removed all the error-silencing @ from WP-Cache2. Ah. It was some problem with class_exists() and APC. Apparently, APC doesn’t play well with class_exists().
Here is the solution I came up with… it seems to be working. I’ve been able to enable/disable WP-Cache2, restart Apache2, flush APC, with no White Page of Death so far!
[ I have removed my solution, to keep from misleading people, as it gave me problems later on ]
Restart Apache, flush your WP-Cache2 cache, and cross your fingers. I’ll update if I have any problems with this.
Update: Well that was short-lived! I’m still looking for a solution. It may involve naming the wp-cache-config.php file differently for each WP install that is running WP-Cache2.
Update 2 (SOLUTION): This seems promising. In php.ini in the [apc] section I set apc.filters = wp-cache-config which should exclude wp-cache-config.php and wp-cache-config-sample.php from being cached by APC.
Update 3: Yep! That did it!

Good luck with this =). I will be keeping an eye out to see what you come up with and I just hope that there is a solution that doesn’t require access to php.ini (although I know some php.ini settings can be changed from within a script itself, kind of like how .htaccess can change httpd.conf settings).
Tony Rayo
February 20, 2006 at 10:33 am
Great solution, I kept disabling APC whenever I needed to access the administration panel. Using your solution saved me the hassle.
Hossam Hossny
March 18, 2006 at 7:53 am
Same configuration, almost the same problem. I did this:
apc.filters = “-.*cache.*\.php”, “podpress\.php”;
podpress wasn’t working for me…
buttermyself
March 19, 2006 at 1:21 pm
hi
i recently installed wp-cache and all it does is cache /feed/ and not anything else. http://technopedia.info/tech
What are the filenames that are to be provided in the list of files to be cached?
thanks
Abs
Abhinav Kaiser
March 29, 2006 at 10:05 am
Aha. That’s what I needed. I was just trying to install APC today, and ran into the blank-page problem. Filtering out wp-cache-config seems to have things working. I wonder why it conflicts like that?
Dougal Campbell
April 27, 2006 at 1:58 pm
WP-Cache2 declares a class conditionally… and apparently APC doesn’t do well under those circumstances. I believe the error was due to the class not existing, because APC thought it didn’t when it should have. Blank page because errors are all turned off and everything is @silenced. I experimented with all sorts of things to make it work, but with no luck. This might change as APC matures… I hear it is under consideration for PHP6, but for now, filtering out wp-cache-config is a viable workaround.
Mark Jaquith
April 27, 2006 at 2:36 pm
[...] APC has a couple of caveats, of course. Using it with WP-Cache could be tricky. Mark has some things to say about using WP-Cache with APC that might interest you. I decided that I liked the full dynamic availability of my site more than the downsides of WP-Cache. Also, I was seeing more benefit from APC, anyway – my site was noticeably faster. And APC will affect other PHP applications positively as well. So it was all upsides for me with APC. [...]
High Performance WordPress - Asymptomatic
May 2, 2006 at 7:05 am
WordPress Tuning fr bessere Performance
Die Bloggerszene wchst und wchst und viele Blogger setzen zur Ausbung ihrer Sucht / ihrem Hobby auf das Weblog-System namens “WordPress”. WordPress basiert auf PHP und MySQL, ist frei erhltlich und wahrscheinlich nicht zuletzt dank sein…
sitepoint Blog
May 4, 2006 at 3:45 pm
[...] The first action I implemented was installing Alternative PHP Cache or APC. APC speeds up loading times by caching compiled WordPress PHP files so that the loading time the next time a page is loaded is much faster. This is different to WP-Cache2, which stores the HTML of a page for a user-defined period, which can cause problems if new comments or posts are made within this period i.e. if the page changes. APC doesn’t suffer from this problem and all page loads are dynamic. APC and WP-Cache2 currently can’t be installed at the same time, although Mark Jaquith is working on trying to get the best of both worlds by finding a way to get APC and WP-Cache2 to work together, and I’m pretty sure he will crack it soon. However, given that I can’t even get WP-Cache2 to work by itself I didn’t even attempt to try some of Mark’s experiments. Initially I struggled to install APC as until two weeks ago when I moved from Blogware to WordPress I’d never even used MySQL before, much less configured a server. Luckily I found these instructions by Matthew Carroll on how to install APC which I almost managed to complete by myself, but Matthew was kind enough to finish the job for me. [...]
Guide To Optimizing WordPress Servers » Connected Internet
July 22, 2006 at 5:53 am
How about something like PHPA which is also free and has gotten good reviews.
http://www.php-accelerator.co.uk/
It’s supposedly better than zend and yahoo uses it.
Works with php 4.4.1 too.
I don’t have it (or root) on my current host or I’d try it, but I’ve had it on previous hosts and it’s transparent.
_ck_
July 29, 2006 at 6:18 am
Hm, I’m now seeing a very similar issue with wp-cache2 and php-eaccelerator.
Michael Hampton
August 2, 2006 at 9:31 am
[...] 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. [...]
benchodroff.com - » PHP Caching with APC and WP-Cache
August 2, 2006 at 6:07 pm
I am running the latest APC and WP-Cache and I’m getting the ‘white page of death’ error. I have tried a variety of filter settings in apc, flushing the wp-cache, and restarting apache. No luck yet. Mark – do you have WP-Cache successfully working with APC? As of now, I’m just going to use APC.
Any other suggestions?
Benjamin Chodroff
August 2, 2006 at 6:27 pm
Unfortunately, no luck here as well. Just as Ben’s problem; blank screen on first load, but subsequent loads work. I have removed all error suppressions from all wp-cache files. Even my log files are completely clean (after a couple file_exists() additions to the code. I’m still troubleshooting though…
Philip
September 2, 2006 at 6:53 pm
[...] Anyway, it appeared other people have been having problems with getting these two bloody beasts to work together, too. So, I decided to take the task on myself to figure out just why these two are having temper-tantrum, even after adding the suggested fix by Mark Jaquith. [...]
Delusioned :: APC with WP-Cache - It lives!
September 2, 2006 at 7:21 pm
Solution has been discovered! I have posted the solution on my blog for details, but so you know I’m not link spammin ya, here’s how: Edit wp-cache-phase2 list 219. Change ob_end_clean() ob_end_flush().
The problem is ob_end_clean() cleans out the buffer without actually flushing it to the screen and I don’t see any flush() calls before hand. Changing it to ob_end_flush() will end the output buffer and flush all data to standard out.
I have tested this solution with and without APC and it seems to be working.
Philip
September 2, 2006 at 7:25 pm
[...] Mark Jaquith [...]
Thanks WP-Cache!!! « Jayant Kumar Gandhi
October 3, 2006 at 12:58 am
Sounds great, but what about non techies like me? How to install it safe?
milo
November 10, 2006 at 4:17 am
[...] This is the clever bit that Mark Jaquith came up with, which is actually quite simple in the end. To get APC to work with WP-Cache2 make the following changes: In php.ini in the [apc] section, set ‘apc.filters = wp-cache-config’ to exclude wp-cache-config.php and wp-cache-config-sample.php from being cached by APC [...]
Ultimate Wordpress Site Speed - Install WP-Cache2 AND APC At The Same Time » Connected Internet
December 23, 2006 at 10:26 pm
[...] So here’s a guide for installing APC on Ubuntu. And here’s a fix when using WordPress and WP-Cache with APC. [...]
Cow Powered » Blog Archive » Speeding up Wordpress with APC
January 1, 2007 at 5:53 pm
[...] APC is a free PHP cache that can provide (allegedly) up to a 50% speed increase on your server. It’s actually not WordPress specific, any PHP based site could get a boost out of it. The biggest downside is that you have to restart the server every time you change a PHP page. If you’ve finished working on your site for a while and are ready to let it run, APC might be a great choice. If you want to run it along side of WP-Cache, you’ll need to take a look at this article. [...]
Circle Six Blog » Blog Archive » DiggProof your Wordpress
January 22, 2007 at 10:28 pm
Instead of APC I use eAccelerator, and it’s a beast. My site blazes, man, and there are 0 compatibility problems.
Elliott C. Bäck
January 23, 2007 at 8:54 pm
[...] Adventures with WP-Cache2 & APC [...]
Mahmood’s Den » Blog Archive » New AJAX Comments module installed
January 31, 2007 at 11:20 am
Hi there,
I was new to wordpress and those plugin staff. I had install this wp-cache plugin. I had enable the plugin from the optioin there.
So how can i know that this plugin had take effect and how can i view the statistic thing?
Anyhting to be check and any setting needed?
Thanks
Eric
eric
February 6, 2007 at 1:01 am
[...] once. Note: If you want to use this plugin and the PHP Compiler Cache APC together, have a look at this posting from Mark [...]
Firdaus Progressindo Purwa » speed up wordpress » Blog Archive
February 16, 2007 at 9:20 pm
4+1 maneras de mejorar la velocidad de WordPress
Arne Brachhold ha escrito 4+1 Ways To Speed Up WordPress y aprovecho para resumir lo que dice y ampliarlo en algún punto:
Activar el MySQL Query Cache. Lo único que tenemos que hacer es buscar el fichero de configuración de MySQL (my.cnf o my.ini)…
SigT
February 17, 2007 at 5:53 am
[...] Adventures with WP-Cache2 & APC « Mark on WordPress (tags: wordpress plugins cache howto) [...]
links for 2007-02-25 at Idealabs
February 25, 2007 at 2:22 pm
[...] Páginas estáticas. Usar WP-Cache, nada nuevo, solamente añadir un enlace a un post de Mark Jaquith que explica cómo combinar APC+WP-Cache sin conflictos. [...]
zlim! » Blog Archive » 4+1 maneras de mejorar la velocidad de WordPress
February 25, 2007 at 9:55 pm
I am sorry for breaking WP-Cache/WP-Cache2 with APC … with a decent enough test case, that bug was fixed for good today (for php4, php5 having had that fix for months).
t3rmin4t0r
March 20, 2007 at 11:17 am
APC + WP-Cache
wordpress 終極 (?) 加速技 !!
從不久前開始義氣幫用的 colo 主機的 PHP 常常會抓狂猛 core dump,然後我的 blog 常常會吐空白頁 (可是其他人的不會),access log 裡面記錄的是 http code 是 200,長度為 0;…
苦牢之最後一年
March 24, 2007 at 5:49 am
t3rmin4t0r,
Thanks for the update!
Mark Jaquith
March 26, 2007 at 2:39 am
[...] Mark Jaquith – Adventures with WP-Cache 2 and APC [...]
WordPress Wednesday: New Security Release, Updated WordPressMU, More WordPress Plugins, and Time to Get Naked at The Blog Herald
April 4, 2007 at 7:01 pm
[...] Mark Jaquith – Adventures with WP-Cache 2 and APC [...]
WordPress Wednesday: New Security Release, Updated WordPressMU, More WordPress Plugins, and Time to Get Naked » TechAddress
April 9, 2007 at 10:46 am
[...] to “encourage” Alex King to update his Popularity Contest plug-in for WordPress to be WP-Cache2/APC compatible. When I was out in Denver last month, Alex said he had plans to do it, and that he had [...]
Alex King’s Popularity Contest plug-in for Wordpress | Eric Cheng’s Journal
April 30, 2007 at 1:52 am
[...] possible gotcha – http://markjaquith.wordpress.com/2006/02/13/adventures-with-wp-cache2-apc/ [...]
The WordCamp Report » HyperDB and High Performance WordPress PLUS
July 22, 2007 at 2:05 pm
[...] once. Note: If you want to use this plugin and the PHP Compiler Cache APC together, have a look at this posting from Mark [...]
菠萝艾蔻 » 4+1 Ways To Speed Up WordPress With Caching
August 26, 2007 at 10:58 am
[...] once. Note: If you want to use this plugin and the PHP Compiler Cache APC together, have a look at this posting from Mark Jaquith. Advertise Here ! No related [...]
McBOX » Blog Archive » Ways To Speed Up WordPress With Caching
December 30, 2007 at 8:02 pm
[...] once. Note: If you want to use this plugin and the PHP Compiler Cache APC together, have a look at this posting from Mark Jaquith. Bookmark To: | del.icio.us | Digg it | reddit | Spurl | StumbleUpon | [...]
McBOX » Blog Archive » Ways To Speed Up WordPress With Caching
December 31, 2007 at 9:36 am
I just found this. Interesting article as I am setting up a multi-server architecture for something unrelated to blogging and was investigation PHP opcode cache, APC and eAccelerator.
I plan to host my own blog on my own server in a colo soon (in the near future) so I will let you know how it goes.
btard
January 25, 2008 at 11:11 am
[...] Adventures with WP-Cache2 & APC « Mark on WordPress [...]
breaker of stuff, destoryer of things, sometimes ninja | configuring wp-cache to work with apc
April 23, 2008 at 6:51 am
[...] Adventures with WP-Cache2 & APC « Mark on WordPress Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages. [...]
configuring wp-cache to work with apc | breaker of stuff, destroyer of things
May 15, 2008 at 7:52 am
[...] Somit sollte eigentlich die kses.php ausgeschlossen werden, da jene (jedenfalls früher) öfters zu Problemen bei APC (und anderen OP-Caches) geführt hat, weiterhin werden die von wp-cache2 bzw. wp-super-cache erstellten wp-cache HTML Dateien nicht beachtet. Auch hier gilt es, erstmal ohne probieren und sollte es Fehler geben (Seg Faults etc.) Logs ansehen und Datei ausschliessen, oder eben default obrige Einstellung verwenden. Einen sehr guten Artikel hierzu findet man z.B. hier. [...]
PECL APC Cache installieren - eAccelerator, Pfad, PECL, OP-Caches, Befehl, Datei, Optimizer, Paket - LazyBrain.de
June 13, 2008 at 5:21 am
[...] Adventures with WP-Cache2 & APC [...]
A Non-Traditional Wordpress Tuning Guide - Part II | Online Shopping Network
August 17, 2008 at 4:10 pm
[...] once. Note: If you want to use this plugin and the PHP Compiler Cache APC together, have a look at this posting from Mark [...]
เพิ่มความเร็ว Wordpress ฉบับลูกครึ่งไืทย-อังกฤษ | iDatabase Blog l บันทึกออนไลน์ของคนทำเว็บ ปี 1
October 10, 2008 at 8:50 am
where to download APC (Alternative PHP Cache)? thanks
Anton Ongsono
December 24, 2008 at 9:23 pm
was new to wordpress and those plugin staff. I had install this wp-cache plugin. I had enable the plugin from the optioin there.
Rap
December 26, 2008 at 9:36 am
[...] Duct Tape –>pr4 Aral Balkan – Another day, another App Engine issue – solved! –>>pr4 Adventures with WP-Cache2 & APC Mark on WordPress –>pr4 Protegidas | Best Free WordPress Themes –>pr4 Backlink Check –> pr4 [...]
yabanc yksek prli bloglar bele backlink - Teknoloji ve Webmaster Platformu
March 8, 2009 at 2:19 am
use eAccelerator, and it’s a beast
komik videolar
April 7, 2009 at 5:15 pm
Adventures with WP-Cache2 & APC
dizi izle
June 5, 2009 at 1:29 pm
[...] once. Note: If you want to use this plugin and the PHP Compiler Cache APC together, have a look at this posting from Mark [...]
4+1 Ways To Speed Up WordPress With Caching | rapid-DEV.net
June 15, 2009 at 1:28 am