- How do I install werk365/etagconditionals in a Laravel app?
- Install it with Composer, then register the package middleware in app/Http/Kernel.php or bootstrap/app.php for Laravel 11. You can optionally publish any package configuration. Confirm the Composer constraints match your Laravel version and test in a sandbox app first.
- Which Laravel and PHP versions does werk365/etagconditionals support?
- The last release was March 2023, so it likely targets Laravel 9 or 10 and PHP 8.0 or newer. Laravel 11 and 12 compatibility is unverified in the evaluation. Check the package composer.json and run integration tests before relying on it in production.
- How does werk365/etagconditionals generate ETags?
- The package adds middleware that generates ETags and compares them with conditional request headers. The evaluation flags the hash algorithm, whether the ETag is body-only or full-response based, and weak versus strong tag behavior as key questions. Inspect the source and configuration, then test the exact behavior for your responses.
- Does it support If-Match and If-None-Match for PUT, PATCH, and DELETE?
- The package is intended to honor If-None-Match and If-Match to return 304 Not Modified or 412 Precondition Failed. It is especially relevant for optimistic concurrency on unsafe methods, but middleware ordering is critical there. Test wildcard values, multiple ETag lists, and each HTTP method you plan to support.
- Can I customize the 412 Precondition Failed response body?
- The evaluation explicitly asks whether the default 412 response body is customizable, so verify this against the package source or configuration. It likely returns a standard Laravel response, but do not assume without testing. If needed, handle customization through your exception handler or a small wrapper middleware.
- Does werk365/etagconditionals work with Laravel Octane and response-changing middleware?
- Octane and middleware that mutates responses, such as compression or encryption, are identified as areas needing verification. ETags must be computed on the final response and should exclude volatile headers such as Date. Test with Octane, reverse proxies, and CDNs that may strip or rewrite ETag and If-Match headers.
- How is this different from Laravel's built-in ETag support or CheckResponseForModifications?
- Laravel already provides some ETag and response modification handling, while this package adds conditional request middleware including If-Match behavior for unsafe methods. The evaluation describes it as filling a gap for optimistic concurrency with 412 responses. Test the interaction carefully if you also use Response setEtag or Laravel's built-in middleware.
- Is werk365/etagconditionals actively maintained and safe for production?
- The last release was March 2023, with around 90 stars, no dependents, and no commercial support, so maintenance risk is real. Low adoption means fewer production edge cases have been exercised. For production, pin the version, fork if necessary, add tests for your critical paths, and monitor compatibility.
- How should I test conditional GET and optimistic locking flows with this package?
- Write integration tests for 200, 304, and 412 flows, plus 428 Precondition Required where appropriate. Cover GET with If-None-Match and PUT, PATCH, or DELETE with If-Match, including wildcard and multiple ETag cases. Also test middleware ordering and the final response after compression or other mutations.
- Can I apply werk365/etagconditionals only to selected API routes?
- Yes, the middleware can be applied per route or globally, so you can start with low-risk GET endpoints. For write endpoints, require clients to send If-Match from a prior GET and return 412 on mismatch. Ensure gateways, proxies, and CDNs preserve the ETag and conditional headers.