|
/ Documentation /Code Snippets/ How to Allow Cache Plugins to Cache the CartFlows Pages?

How to Allow Cache Plugins to Cache the CartFlows Pages?

By default, CartFlows prevents its pages from being cached by common caching plugins. This is done to avoid potential conflicts and ensure that funnel steps work correctly out of the box.

However, if you understand the implications and want to allow caching on CartFlows pages for performance reasons, this documentation explains how to do it.

Why CartFlows Pages Are Not Cached

CartFlows includes special constants in its code that instruct caching plugins to skip its pages:

  • DONOTCACHEPAGE
  • DONOTCACHEOBJECT
  • DONOTCACHEDB

Many popular caching plugins look for these constants, and when detected, they automatically exclude the page from being cached.

How to Allow Caching for CartFlows Pages

You can disable this restriction by using a filter provided by CartFlows. This filter allows you to override the default behavior and selectively allow caching for specific step pages.

Add This Filter to Your Child Theme

To allow caching, add the following code to your child theme’s functions.php file:

add_filter( 'cartflows_do_not_cache_step', 'cache_CartFlows_pages' );

function cache_CartFlows_pages( $post_id ) {
 
// If you want to remove more pages from the cache then add those page's id in the array.

	if( in_array( $post_id , array( 'add_your_landing_page_ids_comma_separated_id_more_than_one' ) ) ){
		return false; // Cache the Pages.
	}

	return true; // Do Not cache.
}

You can find your step page IDs by going to CartFlows > Funnels, opening the Funnel, then hovering over the Step name to view the ID in the URL.

Step ID

In the screenshot above, the Step ID is 68.

How to Add Custom Code Safely

If you’re not sure how to add code to your functions.php file, follow this guide: How to Add Custom Code to WordPress

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page
Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Free Cartflows Form - Popup

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.