Strong and Weak ETag Comparison
A weak ETag can match a byte-different representation under weak comparison, which ignores the W/ prefix and compares only the opaque tag; strong comparison requires both tags to be strong and identical.
The short answer
An entity tag is an opaque validator written in quotes, optionally prefixed with W/ to mark it weak. Strong comparison succeeds only when both tags lack the W/ prefix and their opaque tags are identical character for character. Weak comparison removes the prefix from each tag and then compares the opaque tags, so a weak tag can match a representation whose bytes differ, provided the server asserts the representations are semantically equivalent.
The consequence is easy to state: W/"abc" matches "abc" and W/"abc" under weak comparison, but only "abc" matches "abc" under strong comparison. RFC 9110 assigns weak comparison to If-None-Match and strong comparison to If-Match and If-Range.
A minimal example
Suppose a page has a gzip-encoded and an identity-encoded representation that the server treats as equivalent. The server can give both the same weak tag.
HTTP/1.1 200 OK
Content-Encoding: gzip
ETag: W/"page-42"
Vary: Accept-Encoding
A client with stored W/"page-42" revalidates:
GET /page HTTP/1.1
If-None-Match: W/"page-42"
The origin uses weak comparison, the tags match, and it returns 304 with no body. The client keeps the bytes it already has; the weak tag does not claim those bytes match another variant byte for byte. Why Does an HTTP 304 Response Have No Body? covers the response framing.
Comparison rules
| Property | Strong comparison | Weak comparison |
|---|---|---|
Both tags must lack W/ |
Yes | No |
| What is compared | Opaque tags, character for character | Opaque tags after removing W/ |
W/"a" against "a" |
No match | Match |
| HTTP fields that use it | If-Match, If-Range | If-None-Match |
| Suitable for byte ranges | Yes | No |
The table is the whole distinction. The prefix is not part of the opaque tag; it is a flag on the validator. A server that emits W/"a" is saying the bytes may differ from another representation with the same opaque tag, while "a" is saying they do not.
When a weak tag is appropriate
Weak validators fit cases where byte equality is too strict: content coding, insignificant formatting changes, or a representation assembled from equivalent sources. A cache can validate with weak comparison because it needs to know whether the stored response remains usable, not whether a byte range can be resumed. A strong tag promises identical bytes, which is what a range request needs.
Do not weaken a tag merely to avoid computing one. If the bytes can change while the tag stays the same, caches and clients will keep serving the old representation. A weak tag is a promise of semantic equivalence, not permission to reuse a validator across unrelated content.
Edge cases
If-Range requires a strong validator, so a range request carrying a weak ETag receives the full representation instead of 206. If-Match also uses strong comparison, so If-Match: W/"v1" cannot succeed and a failing condition produces 412. The wildcard * in If-None-Match is not an entity tag comparison at all: it matches whenever a current representation exists.
Entity tags are scoped to a resource and representation, not globally to an origin. Two different URLs can legitimately use the same opaque tag, and proxies must not merge them. An ETag also need not be a hash; it only has to change when the representation changes and be precise enough for the comparisons above.
Practical checks
Ask for headers, then repeat the request with a deliberately weak validator.
curl -sSI https://example.com/page
curl -sS -o /dev/null -w '%{http_code}\n' \
-H 'If-None-Match: W/"page-42"' \
https://example.com/page
Expect 304 from If-None-Match when the current tag matches under weak comparison, and 412 from a request whose If-Match uses a weak tag. A satisfiable Range request can return 206; when If-Range is present, it must carry a strong validator, otherwise the server sends the full 200 representation. A step-by-step check is in Validate an ETag with curl; post-validation cache behavior is covered in Freshness and Validation in Cache-Control.
Sources
Revision history
- Published
- Updated
- — Initial publication.