• Resolved Martin Kilarski

    (@kmarcink)


    Hi,

    We use “Post Grid by PickPlugins” to display a list of posts on a custom page. After we add or update a post, the list of posts is on the page is updated for admins, but not for not logged-in users.

    We have tried clearing it when a post is updated. But the clear cache function does not return anything.

    function automate_clearing_overview_pages_cache( $post_id, $post, $update ) {
      $post_type = $post->post_type;
    
      if ( 'post' === $post_type ) {
        if (function_exists('sg_cachepress_purge_cache')) {
          $result = sg_cachepress_purge_cache('https://mysite.com/newsroom/');
        }
        return;
      }
    
      return;
    }
    add_action( 'save_post', __NAMESPACE__ . '\automate_clearing_overview_pages_cache', 10,3 );
Viewing 7 replies - 1 through 7 (of 7 total)
  • I am also using this function sg_cachepress_purge_cache but it is not clearing the cache. I am using it to clear the cache after a new comment is approved but it does not work. Should it clear the file based cache too?

    Plugin Author Elena Chavdarova

    (@elenachavdarova)

    Hello @kmarcink,

    Could you please confirm if you are using the latest version of the plugin – 7.0.3, as there was an update of the exact same method released today.

    Additionally confirm if the URL you are clearing is publicly accessible, or private.

    As for the question of @confusedneedhelp, yes, the method should flush the File-Based cache too. Please update the plugin and report back the results.

    Thank you for your cooperation.

    Best Regards,
    Elena

    Thanks, working for me now after the update.

    [deleted]

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    Awesome, marking as solved!

    Thread Starter Martin Kilarski

    (@kmarcink)

    Hi,

    I have:
    SiteGround Optimizer – Version 7.0.3
    WordPress – Version 5.9

    Updating a plugin did work for us.

    We have found out that it was actually WP Rocket that was causing the cache not to be cleared.

    The following code fixed the problem:

    
    <?php
    namespace My_Site\Plugins\WP_Rocket;
    
    /**
     * Automate clearing cache for overview pages
     */
    function automate_clearing_overview_pages_cache( $post_id, $post, $update ) {
    	$post_type = $post->post_type;
    
    	// when post is updated
    	if ( 'post' === $post_type ) {
    			if (function_exists('rocket_clean_post')) {
    				$result = rocket_clean_post(19380); // Newsroom page
    			}
    			return;
    	}
    
    	return;
    }
    add_action( 'save_post', __NAMESPACE__ . '\automate_clearing_overview_pages_cache', 10,3 );
    

    Thank you for your awesome and fast support! You rock!

    Plugin Support ivandzh

    (@ivandzh)

    Thank you for the update.

    We are glad that the issue has been resolved.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Smart cache does not clear cache on all overview pages’ is closed to new replies.