Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Etagconditionals Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • API platform strategy: HTTP caching layer. This package lets a Laravel API emit 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.
  • Feature roadmap: optimistic concurrency control for mutable resources. 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.
  • Build vs. buy vs. ignore. Scoped as a thin middleware layer over framework primitives. The build option is maybe a day of engineering plus permanent ownership of edge cases (weak vs. strong validators, Vary interaction, cache header correctness). Buying here is essentially free under MIT; the decision is really adopt vs. defer, not build vs. buy.
  • Use cases worth naming in the PRD: public/federated read APIs polled by mobile or partner clients; GET-heavy endpoints where payloads are large relative to headers; PATCH/PUT flows where lost updates are unacceptable; JSON:API-style contracts where conditional requests are expected; any API that already sits behind a CDN and benefits from correct revalidation semantics.
  • Vendor and platform hygiene. A 90-star, zero-dependent, last-released-March-2023 package is not a strategic dependency — it is a small piece of HTTP plumbing. Adopting it is a low-stakes bet that is cheap to fork and cheap to replace, which itself is a useful thing for the roadmap to be able to say out loud.

When to Consider This Package

Adopt when:

  • You have a resource-oriented Laravel API (or are about to expose one) where clients re-fetch the same representations repeatedly — dashboards, sync clients, mobile lists, partner integrations.
  • You need conditional writes and want them enforced centrally in middleware rather than re-implemented per controller. Consistency across fifty endpoints is the whole value.
  • You care about standards-correctness (RFC 7232 semantics) but don't want to own the nuance: If-None-Match: *, multiple ETags, weak vs. strong comparison, Vary interplay.
  • The team is small and the alternative is "someone writes this during a sprint and it never gets tests." A tested MIT middleware is a better default than bespoke code.
  • You are already on a supported Laravel version. Verify the illuminate/* constraint in composer.json against your pinned framework before committing; this is the single most likely blocker.

Look elsewhere or defer when:

  • Maintenance risk is disqualifying for you. No release since March 2023 and no dependent ecosystem means no external safety net. Mitigate by pinning, adding integration tests around the middleware, and pre-accepting that "fork and maintain" is the fallback plan. If your org requires active vendor support or an SLA, this fails the bar regardless of technical merit.
  • You need the wider conditional-request surface — 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.
  • Your caching problem is a response-caching problem. If the goal is "don't hit the DB," a response cache or CDN-level caching is the primary tool. ETags reduce transfer and re-render cost, not origin compute, unless ETag generation is itself cheap. Layer them; don't substitute one for the other.
  • Your ETags would be expensive to compute. If producing a validator requires loading and hashing a large aggregate, you have moved the cost, not removed it. Prefer version/updated_at-derived validators from data you already have.
  • Your clients don't speak HTTP properly. Mobile SDKs, generated clients, and internal service calls frequently ignore 304 and 412. If the consuming clients won't implement revalidation or retry-on-conflict, the feature ships and does nothing.
  • You're pre-product-market-fit and the API has three consumers you control. Defer; revisit when a partner or a paying customer asks about conditional requests or lost updates.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
adachsoft/php-code-style