ETag / Conditional Request
A version tag the client sends back so unchanged data gets a tiny 304 response, and stale updates can be rejected before overwriting newer work.
See it
What it is
An ETag is a server-supplied identifier for one representation of a resource. The client sends it back in If-None-Match; if that version is still current, the server replies 304 Not Modified with no response body. This is HTTP's built-in way to validate a cached copy without downloading the whole thing again.
Use conditional GET for data that is read often but changes occasionally. The same mechanism can prevent lost updates: send If-Match with PATCH, and return 412 Precondition Failed if another writer changed the resource first.
The tag belongs to the exact representation, not merely the database row. Compression, selected fields, or content negotiation can change the bytes, so generate validators consistently and send the right Vary headers. Weak ETags start with `W/` and are suitable for cache validation, but not for If-Match's strong comparison.
Ask AI for it
Implement RFC 9110 conditional requests on this resource. Serialize the GET response deterministically, create a quoted strong ETag from its SHA-256 digest, and return it in the ETag header. When If-None-Match matches, return 304 with no body. Require If-Match on PATCH, return 428 when it is absent and 412 when it is stale, then return the new ETag after a successful update. Add tests for match, mismatch, wildcard, multiple tags, and gzip versus identity representations.