After upgrading WordPress to a new version, you might need to clear the APC opcode cache. Here is a simple script that you can store in the root of your website, for example, clearapc.php
:
if (function_exists('apc_clear_cache') && $_GET['pass'] == 'secret') {
if (apc_clear_cache() && apc_clear_cache('user'))
print 'All Clear!';
else
print 'Clearing Failed!';
print '<pre>';
print_r(apc_cache_info());
print '</pre>';
} else {
print 'Authenticate, please!';
}
Then call the script via http://example.com/clearapc.php?pass=secret
Instead of using ?pass=secret
, you might well call the filename something that is hard to guess: clearapc93920.php
I would have thought there would be a hook somewhere in the upgrade script which could be fired automatically instead.
Cache invalidation (be it object or full HTML) is specific to each site and use case, so there is no generic hook.
I stumbled back on this post whilst Googling searching for how to clear APC. Thanks for the handy snippet! I spent a few hours trying to debug something this morning until realising it was the damed object cache causing the problems after a fresh database dump.
One change I might make if I get time, is to do the authentication via a form instead of the URL. It’d be slightly more secure that way. It’s a minor issue though since the worst case scenario is that someone can clear your cache.
Thanks so much for this!
After trying to figure out why an install directory name change caused WordPress to crash, I finally got some idea that it had to do with a php caching issue of some kind. Include calls were trying to use the old path. This cleared it right up :)