matthewbdaly/laravel-etag-middleware
Laravel middleware that automatically adds ETag headers to responses, enabling conditional GET requests and 304 Not Modified replies so clients can cache efficiently and save bandwidth. Simple to register and configure per route.
Architecture fit
ETag and returns 304 Not Modified when the request's If-None-Match matches. No database, queue, cache backend, or external service — it sits entirely inside the framework's HTTP pipeline.app/Http/Kernel.php or scoped to a route group (api, or specific read-only endpoints). Removal is a one-line revert, which keeps the reversibility cost near zero.Integration feasibility
Technical risk
Vary) can produce incorrect 304s or, worse, shared-cache collisions.BinaryFileResponse downloads, SSE, and responses that already set their own ETag (or that a CDN already tags) are all edge cases the middleware does not reason about by default.Response, which already exposes setEtag() / isNotModified(). The functional delta of this package is small.Key questions
composer.json resolve without a fork?If-None-Match and handle bodyless 304s? Any that don't will regress.Stack fit
Build vs. buy
setEtag()/isNotModified() — the team then owns semantics explicitly, which is preferable to owning an abandoned fork.Compatibility and migration path
app/Http/Middleware over an internal fork (smaller long-term surface, no package registry overhead).ETAG_ENABLED) plus explicit route scoping so rollout and rollback are configuration changes, not deploys.Sequencing
curl -I against a single low-risk, read-only GET endpoint: first call 200 + ETag, second call with If-None-Match → 304 and empty body.GET/HEAD if metrics hold; document the exclusion list and the middleware ordering contract.Maintenance
Support
Scaling
Failure modes
304 from non-deterministic bodies → clients show stale data; hardest failure to notice because it looks like a cache bug, not an app error.Vary on personalized responses → cross-user cache bleed if a shared cache sits in front.ETag headers from app + CDN or app + framework.304 as an error.Ramp-up
How can I help you explore Laravel packages today?