Hi,
there is no native way to do this , but here is a quick code snippet
add_action('litespeed_purged_all', 'cloudflare_purge_all');
function cloudflare_purge_all() {
$url = "https://api.cloudflare.com/client/v4/zones/11111111/purge_cache";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Authorization: Bearer xxxxxx",
"Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$data = '{"purge_everything":true}';
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_exec($curl);
curl_close($curl);
}
add it into your theme’s functions.php
, replace 11111111
to your zone ID , and replace xxxxxx
to your API token
you can see the zone ID in your CloudFlare dashboard -> domain -> overview page
you will need to create a new API token , with limited capabiltiy as only to purge cache , like this
it will give you a token , put it in above
after you added this code , everytime when LSCWP performs a purge all action , it will also purge CF’s cache
Best regards,