• Resolved asafm7

    (@asafm7)


    Currently only LiteSpeed cache is purged on post update. It will be useful to have Cloudflare cache automatically purged as well.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support qtwrk

    (@qtwrk)

    yes, because we take CF as static file CDN , and usually static files don’t need frequent purge

    if you really want to have this happened , you can try this code snippet

    add_action('litespeed_purged_all', 'cloudflare_purge_all');

    function cloudflare_purge_all() {
    $url = "https://api.cloudflare.com/client/v4/zones/ZZZZZZZZZZONE_IDDDDDDDDD/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 API TOKEEEEEEEEEEEEEEEEN",
    "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);
    }

    update the token and zone ID to yours

    Thread Starter asafm7

    (@asafm7)

    Thanks, @qtwrk. I will try this.

    Although, I’m not sure I understand this comment:

    we take CF as static file CDN, and usually static files don’t need frequent purge

    I use CF for page cache on CDN, similar to LS page cache on the server side.

    If the page changes it makes sense for the page cache to be cleared everywhere. If the CF page cache isn’t cleared, those changes aren’t visible to visitors until it does. Maybe we misunderstood each other.

    Plugin Support qtwrk

    (@qtwrk)

    yes, I understand what you meant , most people uses CF as static cache , instead of page cache

    Hi,

    I’m not sure it’s a good idea to purge the entire cache after publishing a new article.

    Can you give me the code to purge only 2 urls?

    I’d like to purge the home page and the news page.

    Currently, I’m using the official Cloudflare plugin, but LSC is asking me to remove it as it may cause a conflict.

    Thanks a lot!

    Thread Starter asafm7

    (@asafm7)

    Oh, that’s what I meant

    @qtwrk, I didn’t notice the code is for purging everything. This is unnecessary. Cloudflare allows to purge specific URLs and that’s what I meant.

    If you can provide a code for that and consider making it a part of the plugin (as I don’t see any downside to that) it will be great.

    Thanks, @pierreto.

    Plugin Support qtwrk

    (@qtwrk)

    I will forward it as feature request to our dev

    Thread Starter asafm7

    (@asafm7)

    Thanks, @qtwrk.

    Thread Starter asafm7

    (@asafm7)

    Hi, @qtwrk. Is there an update on this by any chance?

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.