Search by

illuma-law / laravel-edge-clear

miguelenes

Standalone Cloudflare cache purging for Laravel

Package info

github.com/eloquage/laravel-edge-clear

pkg:composer/illuma-law/laravel-edge-clear

Statistics

Installs: 64

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 4

v1.0.0 2026-10-23 14:00 UTC

This package is auto-updated.

Last update: 2026-10-30 17:08:15 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 illuma-law/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.