In this knowledgebase article, we’ll show you how to prevent Rank Math from flushing W3 Total Cache.
Preventing Rank Math from Flushing W3 Total Cache
In Rank Math, we use the w3tc_pgcache_flush
function to flush the cache when a post is updated or added to the site. If you don’t want Rank Math to flush the cache, then follow the steps we’ve discussed below.
1 Navigate to the Theme File Editor
First, navigate to Appearance → Theme File Editor (for a Classic Theme) inside your WordPress admin area.
2 Add Code Snippet
Please disable the Sitemap cache by adding the following filter code to your theme’s rank-math.php file to prevent the plugin from running this function. You can further refer to our dedicated tutorial on how to add a filter/hook to your website.
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
Navigate to the rank-math.php file and add the code snippet, as shown below.
3 Update the File
Once you’ve added the code snippet, click on the Update File button to save the changes made to the file.
If you still have questions – you’re always more than welcome to contact our dedicated support team. We’re available 24/7, 365 days a year…