Note: This library is under active development as I expand it to cover Cloudflare API. Consider the public API of this package a little unstable as I work towards a v1.0. See Coverage.

Cache Purge

Usage

Cloudflare API provides extensive configuration for Purge Cached Content, this helper aims to simplify it.

php

use Cloudflare\Configurations\Zones\CachePurge;

$cachePurge = new CachePurge();

$cachePurge
    ->byHosts(['foo.example.com', 'bar.example.com']);

// OR

$cachePurge->everything();

// OR

// byFilesAdvanced can be chained to add multiple files.
$cachePurge
    ->byFilesAdvanced('https://example.com/my-script.js', 'mobile')
    ->byFilesAdvanced('https://example.com/my-script2.js', 'desktop');

$response = $client->zones()->purge('zone_id', $cachePurge);