Ever since WordPress 2.5, the WP Cache functions haven’t been persistent, so the cached objects are only available for the page load (or script run). This means that data stored in the cache resides in memory only and only for the duration of the request.
Upto version 2.5 we could have simply added define(‘WP_CACHE’, true) to the wp-config.php and we got persistent cache features. This is no longer the case and isn’t really very well documented.
The later versions need a Persistent Cache Plugin. I’m not a fan of some of the larger caching plugins like W3 Total Cache or WP Super Cache as they tend to add complexity and can cause other problems. Besides, as developers, we’re better off writing the code ourselves.
Before going any furuther its probably worth pointing out WordPress has two persistent caching methods.
The first method is the WP Transients API,
- Not much documentation
- Only allows caching of objects to the database so may not be faster
The second method is extending the existing WP Object Cache that is currently throughout your WordPress site already.
- Extending this object is much more flexible
- Can extend into APC, memcache or similar
- Provides a fast cache for basic WordPress functions even before you write your own code