Stop WP Rocket Preloading Certain URLs
Keeps WP Rocket's cache preload from crawling URLs you list, such as filtered archive pages, calendars or tag pages, saving server resources on large sites.
Opens WPIDE on
Code
$wpide_skip = array( '/tag/(.*)', '/events/list/page/(.*)', '(.*)filter_(.*)' ); // URL patterns not to preload.
add_filter( 'rocket_preload_exclude_urls', function ( $regexes ) use ( $wpide_skip ) {
return array_values( array_unique( array_merge( (array) $regexes, $wpide_skip ) ) );
} );
Notes
Patterns are regular expressions matched against the URL, e.g. /tag/(.*) or (.*)?filter_(.*).
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.