PHPackages                             justbetter/statamic-cloudflare-purge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. justbetter/statamic-cloudflare-purge

ActiveLibrary[Caching](/categories/caching)

justbetter/statamic-cloudflare-purge
====================================

Addon that hooks into the statamic invalidation process and purges cloudflare caches

2.0.0(3mo ago)22.1k↑655.6%MITPHPPHP ^8.3CI passing

Since Jun 11Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/justbetter/statamic-cloudflare-purge)[ Packagist](https://packagist.org/packages/justbetter/statamic-cloudflare-purge)[ Docs](https://github.com/justbetter/statamic-cloudflare-purge)[ RSS](/packages/justbetter-statamic-cloudflare-purge/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (9)Versions (7)Used By (0)

[ ![Banner](./art/banner.svg)](https://github.com/justbetter/statamic-cloudflare-purge "JustBetter")Statamic Cloudflare Purge
=========================

[](#statamic-cloudflare-purge)

This addon will hook into your already existing statamic invalidation and purge any pages that have been invalidated from your Cloudflare cache.

Requirements
------------

[](#requirements)

- PHP ^8.3
- Laravel ^12.0
- Statamic ^6.7

Installation
------------

[](#installation)

```
composer require justbetter/statamic-cloudflare-purge
```

Usage
-----

[](#usage)

You need a Cloudflare API key with the `Zone.Cache Purge` permission, and set it in your `.env`:

```
CLOUDFLARE_API_TOKEN="token_here"
```

You will also have to define the zone of your website:

```
CLOUDFLARE_ZONE="zone_id_here"
```

Finally, enable the package:

```
CLOUDFLARE_PURGING_ENABLED=true
```

If you have a multistore setup with multiple zones, see the [Configuration](#configuration) section.

This package listens to the `UrlInvalidated` event and adds every invalidated URL to a temp file. It also listens to certain events as defined in the config file to flush the whole cache.

Then, when you run the `statamic:cloudflare:purge` command or the `PurgeCloudflareCachesJob` job, these files will get purged from the Cloudflare cache. As such, you should add this to your `routes/console.php` like so:

```
Schedule::job(\JustBetter\StatamicCloudflarePurge\Jobs\PurgeCloudflareCachesJob::class)->everyFiveSeconds()->withoutOverlapping();
```

Note

Be aware of the [rate limits on the API](https://developers.cloudflare.com/cache/how-to/purge-cache/#availability-and-limits). You're *probably* not going to run into any issues, but it's possible. Especially if you end up calling an everything-purge often and you're on a free plan, or have a lot of sites running on the same Cloudflare account.

Configuration
-------------

[](#configuration)

You can publish the config with the following command:

```
php artisan vendor:publish --provider="JustBetter\StatamicCloudflarePurge\StatamicCloudflarePurgeServiceProvider"
```

### Multiple zones

[](#multiple-zones)

Using the configuration file you can define multiple zones. There are 3 ways of defining the zone in your config:

```
// Single zone
'zone' => 'zone_id',
```

```
// Multiple zones based on statamic site handles
'zone' => [
    'default' => 'zone_id_default',
    'french' => 'zone_id_french',
    ...
],
```

```
// Complete freedom with a callback
'zone' => function() {
    return \App\Facades\Custom::getCloudflareZone()
},
```

### Cache flushing

[](#cache-flushing)

You can define any events that will trigger a full cache purge immediately in the config file. By default, these three events have been defined for this purpose:

```
'flush-events' => [
    \Statamic\Events\GlobalSetSaved::class,
    \Statamic\Events\NavSaved::class,
    \Statamic\Events\StaticCacheCleared::class,
],
```

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance82

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~144 days

Total

3

Last Release

90d ago

Major Versions

1.0.1 → 2.0.02026-03-26

PHP version history (2 changes)1.0.0PHP ^8.1

2.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d00b3f55cd4ae8b8cfb001a644ed6c7a1127a956c24375bcfe16ce12bd89bed?d=identicon)[justbetter](/maintainers/justbetter)

---

Top Contributors

[![Jade-GG](https://avatars.githubusercontent.com/u/32514269?v=4)](https://github.com/Jade-GG "Jade-GG (31 commits)")[![royduin](https://avatars.githubusercontent.com/u/1703233?v=4)](https://github.com/royduin "royduin (2 commits)")[![kevinmeijer97](https://avatars.githubusercontent.com/u/9716909?v=4)](https://github.com/kevinmeijer97 "kevinmeijer97 (1 commits)")[![niekboon](https://avatars.githubusercontent.com/u/81699906?v=4)](https://github.com/niekboon "niekboon (1 commits)")

---

Tags

cachingcloudflarestatamic

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/justbetter-statamic-cloudflare-purge/health.svg)

```
[![Health](https://phpackages.com/badges/justbetter-statamic-cloudflare-purge/health.svg)](https://phpackages.com/packages/justbetter-statamic-cloudflare-purge)
```

###  Alternatives

[psr/simple-cache

Common interfaces for simple caching

8.1k757.1M2.6k](/packages/psr-simple-cache)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k365.0M3.1k](/packages/symfony-cache)[react/cache

Async, Promise-based cache interface for ReactPHP

445124.5M44](/packages/react-cache)[overblog/dataloader-php

DataLoaderPhp is a generic utility to be used as part of your application's data fetching layer to provide a simplified and consistent API over various remote data sources such as databases or web services via batching and caching.

2114.4M6](/packages/overblog-dataloader-php)[spatie/blink

Cache that expires in the blink of an eye

1675.3M10](/packages/spatie-blink)[gregwar/cache

A lightweight file-system cache system

1084.6M23](/packages/gregwar-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
