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:
- A client retrieves data from the server.
- The client modifies the data locally.
- 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
- 400 Bad Request
- 401 Unauthorized
- 402 Payment Required
- 403 Forbidden
- 404 Not Found
- 405 Method Not Allowed
- 406 Not Acceptable
- 407 Proxy Authentication Required
- 408 Request Timeout
- 409 Conflict
- 410 Gone
- 411 Length Required
- 412 Precondition Failed
- 413 Payload Too Large
- 414 URI Too Long
- 415 Unsupported Media Type
- 416 Range Not Satisfiable
- 417 Expectation Failed
- 418 I'm a teapot
- 421 Misdirected Request
- 422 Unprocessable Entity
- 423 Locked
- 424 Failed Dependency
- 425 Too Early
- 426 Upgrade Required
- 428 Precondition Required
- 429 Too Many Requests
- 431 Request Header Fields Too Large
- 451 Unavailable For Legal Reasons