wp-rocket-cache-rejection-and-filters
WP Rocket: cache rejection, filters, and behavior customization
For developers who need to alter WP Rocket's default behavior from a third-party plugin or theme — not to clear cache (that's wp-rocket-cache-invalidation), but to tell WP Rocket "don't cache THIS", "rewrite assets to MY CDN", "treat THIS as a logged-in cookie", "require THIS capability for settings access". WP Rocket exposes ~200 filter hooks for customization; this skill covers the integrator-relevant subset.
Feature-detection still mandatory. WP Rocket is a paid plugin; not every site has it. Filter callbacks fail silently if WP Rocket isn't active (the filter never fires), so detection is less critical here than for direct function calls — but adding the filter wastes nothing if the plugin is missing.
Misconception this skill corrects
"I'll add
rocket_cache_reject_urifilter with a full URL likehttps://site.com/api/foo— that excludes my endpoint."
Wrong format. Verified at wp-content/plugins/wp-rocket/inc/functions/options.php:243, the filter takes URI patterns (path fragments, regex-style), NOT full URLs. WP Rocket compiles them into a regex and matches against the request path without the host:
// WRONG
add_filter( 'rocket_cache_reject_uri', function ( $uris ) {
$uris[] = 'https://site.com/api/foo'; // never matches anything
return $uris;
} );