justbetter/statamic-cloudflare-purge
Composer 安装命令:
composer require justbetter/statamic-cloudflare-purge
包简介
Addon that hooks into the statamic invalidation process and purges cloudflare caches
关键字:
README 文档
README
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.4
- Laravel ^12.0
- Statamic ^6.7
Installation
composer require justbetter/statamic-cloudflare-purge
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 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. This package handles single-request limits automatically, but it does not take into account the per-account 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
You can publish the config with the following command:
php artisan vendor:publish --provider="JustBetter\StatamicCloudflarePurge\StatamicCloudflarePurgeServiceProvider"
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
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, ],
justbetter/statamic-cloudflare-purge 适用场景与选型建议
justbetter/statamic-cloudflare-purge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.51k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 05 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「caching」 「cloudflare」 「statamic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 justbetter/statamic-cloudflare-purge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 justbetter/statamic-cloudflare-purge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 justbetter/statamic-cloudflare-purge 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Query caching for Laravel 5
Symfony bundle for Cloudflare integration: trusted proxies, real client IP detection, forwarded headers.
Statamic Fine Seo addon
Simple PHP caching system that uses a tmp folder in a Linux environment.
Provides support for PSR-6 compatible cache for Yii1 application
统计信息
- 总下载量: 2.51k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-20