Author: Stasyuk Eugene 170 15.03.2024

Cloudabove has the ability to speed up a site by caching on the server. By default, this cache is cleared every 15 minutes. This speeds up the site quite a bit, but it also affects the display of content. For example, in my case, a product review posted by a user did not appear until 15 minutes later.

Clearing the cache is pretty simple. It is based on a GET request to https://scout.cloudabove.com/api/cache/purge. It is important that the request comes from your server, otherwise the API will not accept the request.

In the case of Woocommerce reviews, we will use the comment_post hook and the wp_remote_get() function

function clear_server_cache($comment_id, $comment_approved) {

    if($comment_approved == 1){
        wp_remote_get('https://scout.cloudabove.com/api/cache/purge', array('timeout' => 5));
    }
}

add_action( 'comment_post', 'clear_server_cache', 20, 2 );

In addition, we can clear the cache from the site’s admin area using the button

To make it available, you need to place this file scout-cache-helper.php in the wp-content/mu-plugins folder of our website.

Other articles

DOMSubtreeModified – event on element change action

DOMSubtreeModified – event on element change

DOMSubtreeModified – event on element change

Brief background I had a website in which the forms were configured on the Contact Form 7 plugin. These forms themselves were integrated with Mailchimp. The challenge was this: after a user fills out and submits a certain form, the message should go to the service with a certain tag (Mailchimp tags are the easiest […]