HTTPQUERY
English

If-None-Match

Usage

The If-None-Match header enables cache revalidation based on entity tags. The client includes one or more ETag values received on a previous response. If any listed ETag matches the current resource, the server returns a 304 Not Modified response with no body, and the client reuses its cached copy. If no ETag matches, the server sends a normal 200 response with the updated content.

For safe methods like GET and HEAD, this is the primary cache revalidation mechanism. For unsafe methods like PUT, If-None-Match with the wildcard * prevents overwriting an existing resource, avoiding the lost update problem. The server returns 412 Precondition Failed when a match is found on an unsafe request.

When both If-None-Match and If-Modified-Since appear in the same request, If-None-Match takes precedence. ETag-based comparison is more reliable than date-based comparison because entity tags are opaque identifiers tied to the exact content, while timestamps have one-second resolution and are subject to clock skew.

When the server returns 304, the response includes headers from the original successful response: Cache-Control, Content-Location, Date, ETag, Expires, and Vary.

ETag value

One or more ETag values, each enclosed in double quotes. Multiple values are comma-separated. Both strong and weak ETags (prefixed with W/) are valid.

* (wildcard)

The wildcard * matches any current entity. Used with PUT to prevent creating a resource when one already exists.

Example

A client revalidates a cached resource using a single ETag. The server returns 304 if the resource still matches the given entity tag.

If-None-Match: "abc123"

A client holding multiple cached versions sends all known ETags. The server checks each against the current resource. If any match, the server returns 304.

If-None-Match: "abc123", "def456"

A weak ETag comparison. Weak validators indicate semantic equivalence rather than byte-for-byte identity. The W/ prefix signals weak comparison.

If-None-Match: W/"v2.6"

A PUT request using the wildcard to prevent overwriting. The server returns 412 Precondition Failed if a resource already exists at the target URL.

PUT /api/resource HTTP/1.1
If-None-Match: *