richan-fongdasen/laravel-varnishable
Cache facade, response()->cache()). It extends Laravel’s HTTP middleware stack, making it a natural fit for performance-critical applications (e.g., e-commerce, content-heavy sites).VarnishableMiddleware). This avoids monolithic caching and supports A/B testing or dynamic content exceptions.Cache facade for TTL management, reducing custom logic.X-Varnish, Surrogate-Control) but not Varnish backend (VCL) tuning.ban URL support for cache invalidation (e.g., purge routes).purge logic (e.g., Route::purge()) or event listeners (e.g., ModelObserver) may introduce race conditions or missed invalidations.Cache::forget() + Varnish ban URLs, or adopt a publish-subscribe system (e.g., Laravel Echo + Pusher).VarnishableMiddleware.unless() clauses.Surrogate-Control support.X-Key headers if needed.laravel-debugbar; use Varnishable::disable() in non-cached routes.ban URLs routed?App\Http\Middleware\Varnishable for route-specific caching.VarnishableManager to configure TTLs globally or per-route.Cache::tags or Model::saved to trigger purges.proxy_pass http://laravel-app; in Nginx).Cache::put() with tags for invalidation (e.g., cache:tags).VarnishPurgeJob) for high-traffic sites.composer require richan-fongdasen/laravel-varnishable./products).curl -I http://app.test/products to verify X-Varnish headers.Route::middleware(['varnishable'])->group(function () {
Route::get('/blog/{post}', [PostController::class, 'show']);
});
Post::saved listener).Varnishable::setTTL(3600) or environment variables.unless clauses to exclude admin/API routes:
Route::middleware(['varnishable'])->group(function () {
Route::get('/public', [PageController::class])->unless(fn () => request()->is('admin*'));
});
Middleware facade directly.curl for purge operations (check php -m | grep curl).Surrogate-Control and Cache-Control headers.ban URL endpoint is accessible (e.g., http://varnish:6082/ban).vcl_recv rules).APP_URL matches Varnish’s frontend host.php artisan vendor:publish --tag=varnishable-config.varnish.php for TTLs, purge URLs, and headers.varnishlog or varnishstat.Route::purge() or HTTP PURGE method.503 errors).richan-fongdasen/laravel-varnishable for Laravel version support.vcl_recv/vcl_deliver rules for future adjustments.varnishlog -g request -q "ReqUrl eq '/cached-page'" to inspect requests.Cache-Control: no-cache is used for dynamic routes.Varnishable::purge() returns 200 OK.Surrogate-Control with Cache-Control incorrectly.varnish-cache GitHub.director rules are configured.VarnishPurgeJob).How can I help you explore Laravel packages today?