Download the PHP package justbetter/statamic-cloudflare-purge without Composer
On this page you can find all versions of the php package justbetter/statamic-cloudflare-purge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download justbetter/statamic-cloudflare-purge
More information about justbetter/statamic-cloudflare-purge
Files in justbetter/statamic-cloudflare-purge
Package statamic-cloudflare-purge
Short Description Addon that hooks into the statamic invalidation process and purges cloudflare caches
License MIT
Homepage https://github.com/justbetter/statamic-cloudflare-purge
Informations about the package 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
- PHP ^8.3
- Laravel ^12.0
- Statamic ^6.7
Installation
Usage
You need a Cloudflare API key with the Zone.Cache Purge permission, and set it in your .env:
You will also have to define the zone of your website:
Finally, enable the package:
If you have a multistore setup with multiple zones, see the 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:
[!NOTE] Be aware of the rate limits on the API. 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
You can publish the config with the following command:
Multiple zones
Using the configuration file you can define multiple zones. There are 3 ways of defining the zone in your config:
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: