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).
Great solution, I kept disabling APC whenever I needed to access the administration panel. Using your solution saved me the hassle.
Same configuration, almost the same problem. I did this:
apc.filters = “-.*cache.*\.php”, “podpress\.php”;
podpress wasn’t working for me…
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
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?
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.
[...] 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. [...]
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…
thank you so much for this information!
[...] 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. [...]
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.
Hm, I’m now seeing a very similar issue with wp-cache2 and php-eaccelerator.
[...] 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. [...]
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?
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…
[...] 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. [...]
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.
[...] Mark Jaquith [...]
Sounds great, but what about non techies like me? How to install it safe?
thanks for helpfull links and infos .
Greets
Raul
[...] 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 [...]
[...] So here’s a guide for installing APC on Ubuntu. And here’s a fix when using WordPress and WP-Cache with APC. [...]
[...] 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. [...]
Instead of APC I use eAccelerator, and it’s a beast. My site blazes, man, and there are 0 compatibility problems.
[...] Adventures with WP-Cache2 & APC [...]
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
[...] 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 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)…
[...] Adventures with WP-Cache2 & APC « Mark on WordPress (tags: wordpress plugins cache howto) [...]
[...] 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. [...]
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).
APC + WP-Cache
wordpress 終極 (?) 加速技 !!
從不久前開始義氣幫用的 colo 主機的 PHP 常常會抓狂猛 core dump,然後我的 blog 常常會吐空白頁 (可是其他人的不會),access log 裡面記錄的是 http code 是 200,長度為 0;…
t3rmin4t0r,
Thanks for the update!
[...] Mark Jaquith - Adventures with WP-Cache 2 and APC [...]
[...] Mark Jaquith - Adventures with WP-Cache 2 and APC [...]
[...] 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 [...]
[...] possible gotcha - http://markjaquith.wordpress.com/2006/02/13/adventures-with-wp-cache2-apc/ [...]
[...] once. Note: If you want to use this plugin and the PHP Compiler Cache APC together, have a look at this posting from Mark [...]
Hi
I like it a lot! Good resources here
[...] 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 [...]
[...] 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 | [...]
new york city car insurance quote
dressers Eskimoizeds blame unhappy traumatic
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.
[...] Adventures with WP-Cache2 & APC « Mark on WordPress [...]
[...] 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. [...]
[...] 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. [...]