Clear Cloudflare Cache

We use Kirby and Cloudflare on The Streamable.

This plugin allows us to automatically purge Cloudflare page cache when making changes to pages in the panel to allow changes to be distributed as soon as possible.


Basic usage requires adding your Cloudflare zone and API credentials to your config:

'thestreamable.clearcloudflarecache.cloudflareZoneID' => 'YOUR_CF_ZONE_ID',
'thestreamable.clearcloudflarecache.cloudflareEmail'  => 'YOUR_CF_EMAIL',
'thestreamable.clearcloudflarecache.cloudflareAPIKey' => 'YOUR_CF_API_KEY',

You can also give more granular control about what URLs should be cleared.

'thestreamable.clearcloudflarecache.dependantUrlsForPage'=> function ($hook, $page, $oldPage = null) {
    $urls = [];
    $urls[] = $page->url();
    $urls[] = $page->url() . '.json';
    $urls[] = page('sitemap')->url();
    $urls[] = page('sitemap')->url() . '.xml';
    return $urls;