Purgely
Purgely manages caching behavior for WordPress sites using Fastly as an edge caching solution. The plugin exposes useful APIs to help control how pages on your site are cached, as well as provides sane defaults to make this a plug and play solution for Fastly cache management. The plugin handles the
Purgely manages caching behavior for WordPress sites using Fastly as an edge caching solution. The plugin exposes useful APIs to help control how pages on your site are cached, as well as provides sane defaults to make this a plug and play solution for Fastly cache management.
The plugin handles the following:
- Sets the Surrogate-Control header to control the expiration time for pages
- Sets the stale-while-revalidate and stale-if-error Cache-Control directives for managing these special Fastly behaviors
- Set groups of Surrogate-Keys for all pages to provide purging across multiple pages with one command
- Provides invalidation of posts and related posts on save
Each of these items have sane defaults with ways to override them and configure them to your liking.
Additionally, the plugin exposes a WP CLI command to provide more flexible purging options.
Manual installation
- 01Upload the plugin directory to /wp-content/plugins/
- 02Activate the plugin through the ‘Plugins’ menu in WordPress
WP CLI installation
- 03Run wp plugin install --activate purgely
Configuration
Purgely provides a number of constants that can be used to control the behavior of the plugin and Fastly’s cache. Users who wish to change these values should define the constants in wp-config.php .
After installing, you should define PURGELY_FASTLY_KEY and PURGELY_FASTLY_SERVICE_ID in wp-config.php . The plugin will work without them; however, you will not be able to purge by surrogate key or purge all without configuring these options. To define them copy the following code to your wp-config.php file, update the key to use your key, and the service ID to match the fastly service you’re using: