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.
ETag headers and honor If-None-Match, so read endpoints can return 304 Not Modified with no body. That is a direct lever on bandwidth cost, mobile data usage, p95 latency, and origin/DB load — the kind of infrastructure decision that usually gets made reactively after a traffic spike.If-Match support means clients can send the version they last read and the server rejects stale writes with 412 Precondition Failed. This is the cheapest credible answer to "two users edited the same record and one silently overwrote the other" — a recurring support ticket and a real enterprise procurement checkbox for APIs that handle records, invoices, configs, or documents.Vary interaction, cache header correctness). Buying here is essentially free under MIT; the decision is really adopt vs. defer, not build vs. buy.Adopt when:
If-None-Match: *, multiple ETags, weak vs. strong comparison, Vary interplay.illuminate/* constraint in composer.json against your pinned framework before committing; this is the single most likely blocker.Look elsewhere or defer when:
If-Unmodified-Since, If-Range, range requests, or full RFC 9110 coverage. This package targets ETag plus If-Match/If-None-Match; the rest is yours.updated_at-derived validators from data you already have.304 and 412. If the consuming clients won't implement revalidation or retry-on-conflict, the feature ships and does nothing.To executives: This is a small, MIT-licensed component that makes our API behave the way the HTTP standard intends, and it costs nothing beyond a short integration effort. The upside is concrete and measurable: clients that already have the latest copy of a resource get a 304 instead of a full payload, which cuts bandwidth and mobile data charges and reduces load on our servers; clients writing to shared records can declare which version they edited, which stops the "my change disappeared" class of bug that generates support tickets and erodes trust in the product. It also closes a box that enterprise buyers and integration partners routinely check during technical due diligence. The main caveat is that it is a small community package last updated in 2023, so we treat it as a short, tested piece of plumbing we are willing to own — not a platform commitment. My recommendation is a time-boxed spike on one high-traffic endpoint, then a go/no-go.
To engineering: Middleware-level ETag generation plus If-Match / If-None-Match handling — the unglamorous but fiddly part of RFC 7232 that nobody wants to reimplement five times. Adopting it means conditional request semantics are consistent across controllers and covered by someone else's tests instead of ours. It also means we accept the framework-version constraint as a real dependency: check composer.json against our Laravel pin, pin the package version, and wrap it in integration tests that exercise 304, 412, and the Vary interaction so an upgrade can't silently break cache correctness. Assume we may fork it — budget a few hours, not a quarter.
How can I help you explore Laravel packages today?