Never Cache Certain URLs in WP Rocket
Adds URL patterns that WP Rocket must never cache, such as account, quote or booking pages with personal content, without touching the plugin's settings screen.
Opens WPIDE on
Code
$wpide_patterns = array( '/my-account/(.*)', '/quote/(.*)', '/booking/(.*)' ); // Paths never cached.
add_filter( 'rocket_cache_reject_uri', function ( $uris ) use ( $wpide_patterns ) {
return array_values( array_unique( array_merge( (array) $uris, $wpide_patterns ) ) );
} );
Notes
Patterns are regular expressions matched against the path, e.g. /my-account/(.*). Save WP Rocket's settings once after activating so its config file is regenerated.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.