Slow website? Run our WordPress performance and security benchmark to find out! The Transients API is a great way to cache small pieces of data in WordPress, but there are certain things developers tend to overlook when working with this API. In this post we’ll cover some situations where transient caching is not a good fit, and explore some better alternatives. The Transients API We’re not going to cover the basics of the Transients API in this post, if you haven’t worked with it before, this codex page will get you started. As a developer, there are a few things you should know and keep in mind when working with transients in WordPress: A transient is volatile, and is not guaranteed to exist A transient is stored in wp_options or a persistent object caching backend if present When stored in wp_options, transients are not autoloaded by default Transients don’t expire on their own When a transient is expired, it’s expired Transients are not thread-safe To overcome some of these limitations, numerous plugins, libraries and code snippets have emerged, for example: Mark Jaquith’s TLC Transients library allows developers to serve stale data while regenerating
Share This