Cache Pages With Certain Query Strings in WP Rocket
Tells WP Rocket to keep separate cached copies for URLs with the query parameters you list, such as a currency or filter parameter, instead of skipping the cache for them.
Opens WPIDE on
Code
$wpide_params = array( 'currency', 'filter_color' ); // Query parameters that deserve their own cache.
add_filter( 'rocket_cache_query_strings', function ( $params ) use ( $wpide_params ) {
return array_values( array_unique( array_merge( (array) $params, $wpide_params ) ) );
} );
Notes
Only add parameters that change page content. Re-save WP Rocket's settings after activating.
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.