barryvdh/laravel-httpcache
Adds HTTP caching to Laravel using Symfony HttpCache. Supports reverse proxy-style caching, cache invalidation, and ESI, helping you speed up responses while keeping dynamic content fresh with simple middleware and configuration.
HttpCache component, which is battle-tested but may require familiarity with Symfony’s caching strategies (e.g., Stale-While-Revalidate).app/Http/Kernel.php)..env or service providers.Cache::forget()) or TTL-based expiration may lead to stale data if not managed rigorously.Cache::tags() for grouped invalidation or implement event listeners for model updates.Vary: Accept or Vary: User-Agent can bloat cache storage. Requires testing with diverse client requests.response()->cache()). Override middleware priority if needed.laravel-caching). Test middleware ordering.Http tests or PestPHP for integration tests.Vary headers.)Cache facade), rate limiting, and queue systems.symfony/http-cache package.X-Accel-Redirect or FastCGI caching headers.GET /products, GET /blog/*).POST /orders, GET /dashboard).composer require barryvdh/laravel-httpcache.app/Http/Kernel.php:
protected $middlewareGroups = [
'web' => [
// ...
\Barryvdh\HttpCache\Middleware\HttpCache::class,
],
];
.env:
HTTP_CACHE_DRIVER=redis
HTTP_CACHE_DEFAULT_TTL=300
HTTP_CACHE_IGNORE_ROUTES=admin/*,api/orders
/about, /pricing).Vary: Accept-Language).ProductUpdated event).HTTP_CACHE_HITS env variable or middleware logging).X-Cache: HIT/MISS, Age, ETag).v0.3.10.HttpCache middleware after auth/locale middleware but before response-modifying middleware (e.g., AddQueuedCookies).response()->cache(), disable HTTP cache middleware for those routes.HttpFoundation).config/cache.php) is properly set up..env and config/http_cache.php (if extended).php artisan config:cache) in production.Accept headers, TTL, and ignored routes.Vary headers and compressed responses.dd($request->headers) to inspect cache keys.HttpCacheStore for low-level debugging.barryvdh) with responsive issue resolution.How can I help you explore Laravel packages today?