Clearing cache with scheduled content plugin

There seems to be a conflict with the WP Fastest Cache plugin.
Is there a hook available to trigger the following code when the countdown hits 0 and refreshes?

if(isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')){
$GLOBALS['wp_fastest_cache']->deleteCache();
}

Without clearing the cache, the count down will keep refreshing endlessly. I do not want to disable the cache since this count down is also in the footer on all pages.

Thx!

  • Ivan

    Hi Stephane !

    You can try to create MU plugin ( for example, create {wordpress_folder}/wp-content/mu-plugins/wpmu_clear_faster_cache.php file via FTP ) with the following code

    <?php
    function wpmu_clear_faster_cache( $output, $tag, $attr, $m ) {
    	if ( 'scheduled' === $tag ) {
    		if(isset($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')){
    			$GLOBALS['wp_fastest_cache']->deleteCache();
    		}
    	}
    	return $output;
    }
    
    add_filter( 'do_shortcode_tag', 'wpmu_clear_faster_cache', 10, 4 );

    It should help.

    Best regards,
    Ivan.

  • Stephane

    Great, Thx!

    Am I correct in reading this code as follows:

    "When the 'scheduled' shortcode is triggered/executed, then clear cache"

    Does this mean that on every page with this shortcode the cache is always cleared? Not only when the countdown hits 0 but when the shortcode exists? I hope not, because that would kill the cache and delete it all the time on every visit, but perhaps I'm reading this wrong? :wink:

    Thx!

  • Ivan

    Hi Stephane !

    This code clears the cache only when Open time is in the past. And when a post is open - it doesn't cache but when one is protected - it caches.
    I'm with you on this one that it's not a good solution but I can't find better one. Because we can't understand that the cache of this page was cleared or not.
    For example, the point could be Open time but it's able to have some delay for redirect and in this case Open time and current time won't be the same.
    Also, we can add checking that current time - Open time < 60sec (for example) - but the cache won't clear in this situation: Open time is 1:30pm, current time 1:00pm. A user opens a page and then closes it. Then he returns to this page at 1:32 pm or later. So, our checking isn't true and the cache won't clear and the user won't see a content of this post again.

    Also, the point could be page slug and we can create some post_meta for this post and check it in our code before clearing the cache but you can have several protected parts on one page.

    Best regards,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.