If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

HTTP Status Code 428

The status code 428, also known as "Precondition Required", is used in communication between web servers and clients (like your web browser) to indicate that the server requires a specific condition to be met before it can process a request. This is typically used to prevent a data inconsistency issue known as the "lost update" problem.

Here's a breakdown of the scenario:

  1. A client retrieves data from the server.
  2. The client modifies the data locally.
  3. The client sends the modified data back to the server for update.

However, if another client has also modified the same data on the server between steps 1 and 3, there's a conflict. The first client's update would overwrite the changes made by the second client, resulting in lost data.

To prevent this, the server can require conditional requests. With a conditional request, the client includes extra information in its request that specifies the expected state of the data on the server. The server checks this information and only performs the update if the data hasn't changed since the client retrieved it. If the data has been modified, the server responds with a 428 code, indicating that the precondition (unchanged data) wasn't met and the client's update cannot be applied. The client can then handle this error and potentially retry the update with the latest data from the server.

Other 4xx Status Codes

428 Precondition Required