ETagAn ETag (Entity Tag) is an opaque string identifying a specific version of a resource representation. When the content changes, the ETag changes, so client and server compare it to decide whether a cache is still valid or to perform optimistic concurrency control.
The value is wrapped in double quotes and may carry a W/ prefix indicating a weak validator.
Cache revalidation: when a client caches a resource it stores the ETag and sends it back on the next request as If-None-Match: "<etag>". If the current ETag matches, the server replies 304 Not Modified (no body) to save bandwidth; if not, it returns 200 with a fresh body.
Optimistic locking: sending If-Match: "<etag>" on an update makes the server apply the change only if the resource hasn't changed since, otherwise rejecting with 412 Precondition Failed. This prevents lost-update conflicts when multiple users edit concurrently.
A strong ETag matches only on byte-for-byte identity, while a weak ETag (W/) matches on semantic equivalence, ignoring trivial differences like compression. If-Range for range requests can only safely use a strong validator.
ETag: [W/]"<opaque-validator>"e.g. ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"