We’ll cover the basics of the Transients API, see basic examples, and then discuss common places where this method can be most helpful, like large, complex queries or pulling from an external API. We’ll also discuss how this type of caching is unique, when to use it, and how to scale it for big bursts of traffic.
I’ve got all the working code samples in a plugin that you can look through while we talk. View it in GitHub, or download the repo and apply it to a local WordPress installation to see the code at work. To do that:
- Clone the repo to your plugins directory or download the .zip file.
- Activate the plugin.
- Import the contained .xml file, which will import five posts with shortcodes that execute the functions.
If you use MAMP and want to spin up an installation quickly, I’ve got a shell script for you to do just that.