Overview

You need to condition the request.

Takeaways

  1. The origin server requires the request to be conditional.
  2. Its typical use is to avoid the "lost update" problem, where a client GETs a resource's state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict.
  3. By requiring requests to be conditional, the server can assure that clients are working with the correct copies.

Responses using this status code should explain how to resubmit the request successfully.

Example

HTTP/1.1 428 Precondition Required
Content-Type: text/html
<html>
  <head>
    <title>Precondition Required</title>
  </head>
  <body>
    <h1>Precondition Required</h1>
    <p>This request is required to be conditional; try using "If-Match".</p>
  </body>
</html>

Information

Responses with the 428 status code must not be stored by a cache.

When a precondition header is not matching the server side state, the response should be 412 Precondition Failed.

Related

Further Reading

Specification

428 Precondition Required | The HTTP Working Group

428 Precondition Required

MDN web docs

If-Match header field

MDN web docs