Search by

eloquage / laravel-edge-clear

zagambila

Standalone Cloudflare cache purging for Laravel

Package info

github.com/eloquage/laravel-edge-clear

pkg:composer/eloquage/laravel-edge-clear

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 3

v1.0.2 2026-11-03 10:29 UTC

This package is auto-updated.

Last update: 2026-11-03 15:08:09 UTC


README

Laravel Edge Clear cache network banner

Purge Cloudflare cache and set edge-cache headers from a Laravel application.

Tests Latest Version License

Requires PHP 8.3+ and Laravel 11, 12, or 13.

Install and configure

composer require eloquage/laravel-edge-clear
php artisan vendor:publish --tag=edge-clear-config

Set your Cloudflare zone and API token in .env:

CLOUDFLARE_ZONE_ID=your-zone-id
CLOUDFLARE_API_TOKEN=your-api-token

Purging is enabled only in production by default. Set EDGE_CLEAR_ONLY_IN_PRODUCTION=false to enable it in other environments. Never use real credentials in local or test environments.

Purge cache

use IllumaLaw\EdgeClear\Facades\CloudflarePurger;

CloudflarePurger::purgeByUrls([
    'https://example.com/posts/hello',
    'https://example.com/posts',
]);

You can also purge by tags or clear the whole zone:

CloudflarePurger::purgeByTags(['posts', 'news']);
CloudflarePurger::purgeEverything();

The SetEdgeCacheHeaders middleware adds cache headers to successful GET responses. The optional BypassEdgeCache middleware disables caching for a route:

use IllumaLaw\EdgeClear\Middleware\BypassEdgeCache;
use IllumaLaw\EdgeClear\Middleware\SetEdgeCacheHeaders;

Route::get('/posts', PostsController::class)
    ->middleware(SetEdgeCacheHeaders::class.':600;posts');

Route::get('/account', AccountController::class)
    ->middleware(BypassEdgeCache::class);

Test

composer test
composer analyse
vendor/bin/pint --test

MIT licensed. See LICENSE.