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

Technical Evaluation

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

  • Maintenance risk: Last release March 2023, 90 stars, 0 dependents. No evidence of active maintenance or a broad user base. Laravel 11/12 compatibility is unverified; PHP 8.2+ may expose deprecations.
  • Correctness risk: ETag generation strategy (hash algorithm, inclusion of headers, weak vs. strong tags) is critical. Bugs can cause stale caches, false 304s, or missed 412s—leading to data corruption or security issues.
  • Security risk: Improper handling of conditional headers on unsafe methods (PUT/PATCH/DELETE) could bypass concurrency checks if middleware ordering is wrong.
  • Ecosystem risk: Low adoption means fewer edge cases have been exercised in production. No commercial support; bus factor is effectively one maintainer.

Key questions

  • How does the package generate ETags (MD5/SHA-1, body-only vs. full response, weak/strong)? Is it configurable?
  • Does it support If-Match and If-None-Match for all HTTP methods, including * wildcard and multiple ETag lists?
  • How does it interact with Laravel’s built-in CheckResponseForModifications middleware or Response::setEtag()?
  • What is the default response body for 412 Precondition Failed? Is it customizable?
  • Does it work correctly with Laravel Octane, response caching, and middleware that mutate the response (e.g., compression, encryption)?
  • Are there tests covering RFC 9110 edge cases (e.g., If-None-Match on POST, weak comparison for If-None-Match)?
  • What Laravel and PHP versions are officially supported?

Integration Approach

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

  1. Isolate and verify: Install in a sandbox Laravel app matching production versions. Write integration tests for 200/304/412 flows.
  2. Start with read endpoints: Apply middleware to idempotent GET routes first, observing 304 rates and cache behavior.
  3. Add write concurrency: For PUT/PATCH/DELETE, require clients to send If-Match with the ETag from a prior GET. Return 412 on mismatch and 428 Precondition Required where appropriate.
  4. Harden: Ensure ETags are computed on the final response (after all middleware), exclude volatile headers (e.g., 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

  • Phase 1 (1–2 sprints): Evaluate package, fork if necessary, add tests for critical paths.
  • Phase 2: Enable conditional GETs on low-risk endpoints (e.g., reference data, configuration).
  • Phase 3: Introduce optimistic concurrency on high-value write endpoints (e.g., user profiles, orders) with client SDK updates.
  • Phase 4: Monitor 304/412 metrics, error rates, and cache hit ratios; iterate on ETag generation if needed.

Operational Impact

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

  • Incorrect ETag computation: Hashing only the body while ignoring content negotiation headers can cause clients to cache wrong representations.
  • Middleware ordering: If ETag middleware runs before response-transforming middleware, the ETag will not match the final body.
  • Proxy stripping: Load balancers or CDNs may remove ETag or conditional headers, silently disabling the feature.
  • 412 storms: Overly strict If-Match enforcement without clear client error handling can degrade UX.
  • Performance: Hashing large responses (e.g., multi-MB JSON) adds CPU overhead; consider streaming or disabling ETags for large payloads.
  • Security: Weak ETags on sensitive data may allow cache-based side channels; ensure 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.

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