APC Cache Purge Plugin for WordPress
After a recent WordPress update, I noticed that the admin panel did not correctly reflect the new version as indicated in the footer of the backend panel. I realized that the APC opcode cache was not flushed and therefore held on to cached versions of many updated files. I thought about what other ways this cache could be flushed without restarting the web server or PHP daemon (PHP-FPM) without compromising service availability.
Some subsequent googling later, I found a dirty hack that, although helpful, was somewhat limited by design -- it suggests adding the script to the functions.php file of your theme. This means you'd need to manually insert the code for each theme. Also, apc_clear_cache()
did not work by default with APC version 3.1.3p1. From this, I created a simple, single purpose WordPress plugin to flush the APC cache.
Once activated, you'll get a 'Purge APC' option under the tools menu. Once the option is clicked, the APC cache is flushed and the entries are displayed on the page:
Feel free to fork or submit pull requests to the GitHub repository.
Installation
- Upload
apc-cache-purge.php
to the/wp-content/plugins/
directory - Activate the plugin through the ‘Plugins’ menu in WordPress
- When needed, flush the cache by clicking on ‘Purge APC’ under the Tools section