WordPress comes with an option of keeping cache in a persistent storage, if provided. It provides a great deal of performance since everything that WordPress was doing repeatedly on each page request now can be saved in the persistent cache storage (APC / Memcached / Redis) and retrieve easily & very fastly without doing much work.
The way to activate that is to drop an `object-cache.php` file in your `wp-content` directory which does the heavy lifting for you. Following plugins are available if you want to get started with it:
* APC – [https://wordpress.org/plugins/apc/](https://wordpress.org/plugins/apc/)
* Memcached – [https://wordpress.org/plugins/memcached/](https://wordpress.org/plugins/memcached/)
* Redis – [https://wordpress.org/plugins/redis-cache/](https://wordpress.org/plugins/redis-cache/)
* Another worthy mention, which works with APC / Memcached / Xcache / – [https://wordpress.org/plugins/tribe-object-cache/](https://wordpress.org/plugins/tribe-object-cache/)
You don’t have a reason to not use object caching unless you are stuck with a plugin which doesn’t follow WordPress standards and causes the site to malfunction when a persistent cache storage is used. An example of such a plugin is Wishlist Member plugin.
It simply doesn’t work well with persistent object cache because it updates the options table directly by making SQL queries instead of using functions like `get_option()`, `update_option()` etc.
I needed to solve the problem, where we could atleast store some of stuff in the persistent cache & hence improving performance. The site for which this was done, is a learning portal where all members are logged in, hence full pages were generated dynamically every single time. To take off some of the load, I developed a plugin in which transients are stored in memcached (persistent storage) so that they can be retrieved very quickly without making SQL queries to the database.
I suggest you use this plugin or use it as a starting point to build what you need. Plugins of this kind, require installation & verification by a developer since its a very barebones-prototype plugin, which does the job of saving transients and retrieving them quickly.
Plugin’s repository – [https://github.com/ashfame/Store-Just-Transients-Persistently](https://github.com/ashfame/Store-Just-Transients-Persistently)
It also overrides wp transient delete-all WP-CLI command so that you can flush transients from both database and memcached (persistent cache storage in use).
Its always a good idea to contribute back your work to the plugin if you build on top of it or extend it, so that other community members can gain from it.
Let me know if you have a question that I can help answer.
Leave a Reply