FlyingPress provides action hooks that allow you to run custom logic before or after cache purging. These are useful for syncing third-party caches, logging, or custom workflows.
Where to add this code
You can add these snippets in one of the following places:
Your theme’s
functions.php
fileA custom plugin you create
A plugin like Code Snippets
Before/after purging multiple URLs
Triggered when FlyingPress purges a list of specific URLs.
add_action('flying_press_purge_urls:before', function ($urls) {
// Add your logic here
});
add_action('flying_press_purge_urls:after', function ($urls) {
// Add your logic here
});
Before/after purging a single URL
Triggered individually for each URL being purged.
add_action('flying_press_purge_url:before', function ($url) {
// Add your logic here
});
add_action('flying_press_purge_url:after', function ($url) {
// Add your logic here
});
Before/after purging all HTML pages
Triggered when FlyingPress clears all HTML pages (but not other cached files).
add_action('flying_press_purge_pages:before', function () {
// Add your logic here
});
add_action('flying_press_purge_pages:after', function () {
// Add your logic here
});
Before/after purging everything
Triggered when FlyingPress purges the entire cache directory, including all pages, files, and subdirectories.
add_action('flying_press_purge_everything:before', function () {
// Add your logic here
});
add_action('flying_press_purge_everything:after', function () {
// Add your logic here
});
Best practices
Use these hooks for tasks like clearing custom cache layers, sending notifications, or syncing with external systems.
Avoid running heavy or slow processes inside these hooks to keep purging fast.
Always test in a staging environment before deploying to production.