purge cloudflare cache when litespeed cache purged




Wordpress LScache Plugin: purge cloudflare cache when litespeed cache purged

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi eveyone! litespeed cache is a great plugin. but i need it to call the purge command on cloudflare so the cache on cloudflare would be updated when litespeed cache is purged. how can i achieve this?? anyone can help?! 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) Expand add it into your themes 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 CFs cache Best regards,



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference