werk365/etagconditionals
werk365/etagconditionals adds Laravel middleware for HTTP conditional requests, generating ETags and honoring If-None-Match and If-Match headers to return 304 Not Modified or 412 Precondition Failed responses automatically.
Architecture fit
The package integrates as Laravel middleware, hooking into the HTTP kernel to inspect request headers (If-Match, If-None-Match) and attach ETags to responses. This aligns well with Laravel’s middleware-centric request lifecycle and is suitable for REST APIs that need HTTP caching semantics (304 Not Modified) and optimistic concurrency control (412 Precondition Failed). It does not impose a domain model, making it a cross-cutting concern that can be applied selectively per route or globally.
Integration feasibility
Installation is straightforward via Composer, followed by middleware registration in app/Http/Kernel.php (or bootstrap/app.php in Laravel 11) and optional configuration publishing. The package appears to require minimal boilerplate—typically just enabling the middleware and ensuring controllers return standard Laravel Response objects. For teams already using Laravel’s response pipeline, the lift is low (hours to a few days for a proof of concept).
Technical risk
Key questions
If-Match and If-None-Match for all HTTP methods, including * wildcard and multiple ETag lists?CheckResponseForModifications middleware or Response::setEtag()?If-None-Match on POST, weak comparison for If-None-Match)?Stack fit
Ideal for Laravel-based JSON APIs where clients can benefit from conditional GETs (bandwidth savings, cache efficiency) and safe writes (optimistic locking). It complements Laravel’s existing cache headers but fills a gap for If-Match on unsafe methods. Not suitable for server-rendered HTML unless ETags are desired for full-page caching (rarely worth the complexity).
Migration path
If-Match with the ETag from a prior GET. Return 412 on mismatch and 428 Precondition Required where appropriate.Date), and configure reverse proxies/CDNs to preserve ETags.Compatibility
Confirm the package’s composer.json constraints against the target Laravel version. As of the last release (2023-03-22), it likely supports Laravel 9/10 and PHP 8.0+. Laravel 11+ may require a fork or patch. Also verify compatibility with API gateways (AWS API Gateway, Nginx) that may strip ETag or If-Match headers by default.
Sequencing
Maintenance
Low activity and zero dependents mean the package is effectively community-maintained with a single maintainer. Plan to vendor the code or maintain an internal fork if the project becomes business-critical. Pin the version and monitor GitHub issues for Laravel compatibility breaks. Budget ~1–2 days per quarter for dependency review.
Support
No commercial support. Rely on GitHub issues and source code reading. The small community means fewer Stack Overflow answers; internal documentation and tests become essential. Consider designating an internal owner for the middleware.
Scaling
ETags improve cache efficiency and reduce bandwidth, which helps at scale—but only if ETag generation is deterministic across horizontally scaled instances. Avoid ETags based on timestamps or random values. Reverse proxies and CDNs must be configured to pass through ETag and conditional headers. For write concurrency, If-Match prevents lost updates but requires client cooperation; without it, scaling writes safely becomes harder.
Failure modes
ETag or conditional headers, silently disabling the feature.If-Match enforcement without clear client error handling can degrade UX.Cache-Control: private or no-store where appropriate.Ramp-up
The team needs working knowledge of RFC 9110 conditional requests, Laravel middleware ordering, and HTTP caching semantics. Expect 1–2 days of learning for backend engineers, plus client-side changes for mobile/web teams to store and replay ETags. Testing requires simulating conditional headers (e.g., Postman, integration tests). Given the package’s low adoption and age, a proof-of-concept with thorough tests is strongly recommended before production use.
How can I help you explore Laravel packages today?