Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Cache API

Owen Stowe edited this page May 14, 2020 · 1 revision

Overview

WP Irving has built-in functionality for managing both the node Redis cache running on Irving and WP Irving's component data endpoints. This functionality is fairly robust out of the box, but can also be modified or extended in a number of ways. Code for all of this functionality can be found in WP Irving's cache manager class.

Core features

Out of the box, WP Irving will handle several caching use-cases for you:

  • When a WordPress post is created, updated, or deleted several caches will be purged:
    • Endpoint and Redis cache for the post itself
    • Endpoint and Redis cache for term archives of the post's associated terms
    • Endpoint and Redis cache for user archive of the post's associated author.
  • When a term is created, updated, or deleted, the endpoint and Redis caches will be purged for its archive.
  • When a user is created, updated, or deleted, the endpoint and Redis caches will be purged for that user's archive.

Integrations

WP Irving contains integrations for WordPress VIP Go's cache manager plugin and Pantheon's Advanced Page Cache plugin. These integrations will activate automatically if the above plugins are active on your site.

Extensibility

In addition to the core features of the WP Irving cache class there are several ways in which you can extend caching functionality.

There are three hooks you can use to modify or extend which paths are purged for posts, terms, or users:

  • wp_irving_cache_post_purge_urls - Filter that is passed an array of the URLs to be purged when a post is create, updated, or deleted.
  • wp_irving_cache_term_purge_urls - Filter that is passed an array of the URLs to be purged when a term is create, updated, or deleted.
  • wp_irving_cache_user_purge_urls - Filter that is passed an array of the URLs to be purged when a user is create, updated, or deleted.

In addition, the three methods that apply the above filters can be used directly if you need to create your own caching integration. These functions are get_post_purge_urls, get_term_purge_urls, and get_user_purge_urls respectively. An example of how you might use these functions can be found in the Pantheon integration class.

Clone this wiki locally