When using WP Rocket with preloading in combination with a filter plugin like Filter Everything pro, then your database AND cache folder can explode. We had a site with only around 2000 Products, but with 100 filterable product attributes.
This resulted in wp_rocket_cache table over 2 million entries and the cache folder going up to 200GB. To fix this, we decided to stop wp rocket from caching filtered WooCommerce category pages.
The following code snippet solved our problem:
add_filter( 'rocket_preload_exclude_urls', function( $regexes, $url ) { $url = untrailingslashit( $url ); if(function_exists('is_filtered')){ if ( is_filtered() ) { $regexes[] = $url; add_filter( 'do_rocket_generate_caching_files', '__return_false' ); } } if(function_exists('flrt_is_filter_request')){ if ( flrt_is_filter_request() ) { $regexes[] = $url; add_filter( 'do_rocket_generate_caching_files', '__return_false' ); } } return $regexes; }, 10, 2 );
Update 2025
In addition to the code above you should add this one below. Amazonbot for example is heavily crawling sites and you can block amazonbot with .htaccess and then also not cache filtered URLs + not generating CSS.
function disable_cache_for_filtered_urls() { if ( function_exists( 'flrt_is_filter_request' ) && flrt_is_filter_request() ) { if ( ! defined( 'DONOTCACHEPAGE' ) ) { define( 'DONOTCACHEPAGE', true ); // Disable WP Rocket caching } } if(function_exists('is_filtered') && is_filtered()){ if ( ! defined( 'DONOTCACHEPAGE' ) ) { define( 'DONOTCACHEPAGE', true ); // Disable WP Rocket caching } } } add_action( 'template_redirect', 'disable_cache_for_filtered_urls' );
.htaccess code
# Block Harmful RobotRewriteEngine On RewriteCond %{HTTP_USER_AGENT} (amazonbot|semrushbot|ahrefsbot) [NC] RewriteRule (.*) - [F,L] # END Block Harmful Robot
Unfortunately doesn’t seem to work in 2025