Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Headers
  5. If-Match

If-Match header

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The HTTPIf-Matchrequest header makes a requestconditional.A server will return resources forGET andHEAD methods, or upload resource forPUT and other non-safe methods, only if the resource matches one of theETag values in theIf-Match request header.If the conditional does not match, the412 Precondition Failed response is returned instead.

The comparison with the storedETag uses thestrong comparison algorithm, meaning two files are considered identical byte-by-byte.If a listedETag has theW/ prefix indicating a weak entity tag, this comparison algorithm will never match it.

There are two common use cases:

  • ForGET andHEAD methods, used in combination with aRange header, it can guarantee that the new ranges requestedcome from the same resource as the previous one.
  • For other methods, and in particular forPUT,If-Match can be used to prevent thelost update problem.It can check if the modification of a resource that the user wants to upload will not override another change that has been done since the original resource was fetched.
Header typeRequest header
Forbidden request headerNo

Syntax

http
If-Match: <etag_value>If-Match: <etag_value>, <etag_value>, …

Directives

<etag_value>

Entity tags uniquely representing the requested resources.They are a string ofASCII characters placed between double quotes (like"675af34563dc-tr34").They may be prefixed byW/ to indicate that they are 'weak', i.e., that they represent the resource semantically but not byte-by-byte.However, in anIf-Match header, weak entity tags will never match.

*

The asterisk is a special value representing any resource.Note that this must match asfalse if the origin server does not have a current representation for the target resource.

Examples

http
If-Match: "bfc13a64729c4290ef5b2c2730249c88ca92d82d"If-Match: "67ab43", "54ed21", "7892dd"If-Match: *

Specifications

Specification
HTTP Semantics
# field.if-match

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp