Optimize Wordpress Internal Caching
This is not a post about WP-Cache The plugin. This is a post about wordpress own internal caching mechanism — WP-Cache functions and WP_Object_Cache class. The function used alot inside wordpress for making extensive function calls. The only shame is that the cache is not persistent between request. So, every request will have to generate its cache again. What I'm attempting to do, is implementing persistent cache that last between request.
The first thing before installing the custom cache script that one should check for existing persistence cache app such as Memcached, XCache or APC. Using one of those app is such a performance boost for PHP application. If you don't have those installed on your server, you can always ask the admin. And if all other options is failed. We can use the good-ol file cache. I'm using the combat-proven PEAR Cache Lite library for file caching mechanism.
The second, there are no flushing or expiring mechanism, so I have to create a small plugin for flushing the cache. Usually flushing is needed when you delete or add plugin or theme. Wordpress won't recognize your plugin, since the plugin list gets cached.
How to Try
- Download the cache manager plugin from the link below: http://herdian.ferdianto.com/media/object-cache-manager.php
- Upload the object-cache-manager.php into the wp-content/plugins/ directory
- Enable your plugin, you'll need to enable this first before installing the object-cache file.
- Download the pear Cache_Lite package from the http://pear.php.net/package/Cache_Lite page.
- Extract it, rename the Cache/Lite.php file to Cache_Lite.php
- Download the
object-cache.phpfile from link below:
- Upload both into the wp-content directory on your server
- Create wp-content/pear-cache directory. This directory must be writeable by the webserver. It will store your cached data as file if you decide to use pear cache lite class.
- You;re good to go