If-None-Match
The HTTP If-None-Match request header makes the request conditional, asking the server to return the resource only if none of the provided ETag values match the current version.
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.
Note
Googlebot sends If-None-Match on crawl
requests when the previous response included an
ETag. Servers returning 304 for
unchanged content save processing time and
resources, indirectly improving crawl efficiency.
Servers are also free to return 304
proactively for any Googlebot request when
content has not changed, regardless of whether
the request includes conditional headers. Setting
the max-age field of the
Cache-Control response header
to the expected number of seconds the content
remains unchanged helps crawlers determine when
to recrawl a URL.
Values
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: *
Takeaway
The If-None-Match header makes requests conditional on ETag comparison, enabling efficient cache revalidation through 304 responses and preventing accidental overwrites on unsafe methods through 412 precondition checks.
Note
For SEO and caching assistance, contact ex-Google SEO consultants Search Brothers.
See also
- RFC 9110: HTTP Semantics, Section 13.1.2
- RFC 9111: HTTP Caching
- Google: HTTP caching for crawlers
- Google Search Blog: Crawling December, HTTP caching
- If-Modified-Since
- ETag
- Last-Modified
- 304
- 412
- Conditional-Requests
- Caching
- HTTP headers