Skip W3 Total Cache on Chosen Pages
Tells W3 Total Cache not to page-cache, minify or serve from CDN the pages you choose, using its documented DONOTCACHEPAGE-style constants.
Opens WPIDE on
Code
$wpide_pages = array( 'checkout-custom', 'live-scores' ); // Page slugs or IDs.
$wpide_skip_minify = true; // Also skip minify and CDN.
add_action( 'template_redirect', function () use ( $wpide_pages, $wpide_skip_minify ) {
if ( ! defined( 'W3TC' ) || ! is_page( $wpide_pages ) ) {
return;
}
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', true );
}
if ( $wpide_skip_minify && ! defined( 'DONOTMINIFY' ) ) {
define( 'DONOTMINIFY', true );
}
if ( $wpide_skip_minify && ! defined( 'DONOTCDN' ) ) {
define( 'DONOTCDN', true );
}
} );
Notes
List page slugs or IDs; set $wpide_skip_minify to false to keep minification on those pages.
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.