WordPress plugin
WP REST Cache Pro: Configure Custom REST Caching Without Code
WP REST Cache Pro extends WP REST Cache, which caches REST API responses so repeated requests can be served from cache. The base extension caches default WordPress REST API GET endpoints and custom post type and taxonomy endpoints. Those custom post type and taxonomy endpoints are not cached automatically when they use a custom WP_REST_Controller.
Cache WordPress REST API responses
WP REST Cache Pro extends WP REST Cache, which caches REST API responses so repeated requests can be served from cache. The base extension caches default WordPress REST API GET endpoints and custom post type and taxonomy endpoints. Those custom post type and taxonomy endpoints are not cached automatically when they use a custom WP_REST_Controller.
Configure custom endpoints and relationships
Custom REST endpoints are not cached unless you configure them. With Pro, you can select endpoints and configure relationships through wp-admin without coding. You can also register endpoints programmatically with the wp_rest_cache/allowed_endpoints hook.
For configured endpoints, the plugin tries to detect related content and flushes the related cache when that content is edited. Relationship detection is not flawless, so configure each endpoint to reflect the content its response uses. Automatic flushing for custom endpoints depends on the relationships the plugin can determine.
Control cache time and flushing
- Set how long a cache remains valid.
- Enable automatic cache regeneration and set its interval. You can also limit how many caches regenerate in each process.
- Manually flush all caches or specific caches.
- See how many times each cache has been retrieved.
When you edit a page or post, the plugin automatically flushes caches related to that content.
Set up the base plugin
Install and activate WP REST Cache from Plugins > Add New, or upload the wp-rest-cache folder to /wp-content/add-ons/ and activate it. After activation, check Plugins > Must-Use for the WP REST Cache must-use add-on. If it is missing, copy wp-rest-cache.php from the plugin’s /sources folder to /wp-content/mu-add-ons/. Set the cache timeout under Settings > WP REST Cache, then use Pro in wp-admin to configure custom endpoints and their relationships.