More
More
428 Precondition Required
The server requires the request to be conditional, such as with If-Match.
- Code
428- Reason phrase
- Precondition Required
- Class
- 4xx Client error
- Defined in
- RFC 6585 section 3
- Cacheable by default
- No
What it means
Client error: the problem lies with the request. Repeating it unchanged will normally fail again.
Common causes. APIs that protect against lost updates.
What to do. Fetch the resource, then send its ETag in If-Match.
How clients and crawlers treat it
Google Search. Like every 4xx except 429, it tells Google the content does not exist: an indexed URL is removed from the index, and a new one is not processed. Crawl frequency for the URL gradually drops. Source: Google Search Central, How HTTP status codes, and network and DNS errors affect Google Search.
Caching. Not cacheable by default (RFC 9110 section 15.1 does not list it). A cache stores it only when the response says so with Cache-Control or Expires.
Example response
HTTP/1.1 428 Precondition Required Content-Type: text/plain; charset=utf-8 Precondition Required
How to send 428
location /example {
return 428;
}
RewriteEngine On RewriteRule ^example$ - [R=428,L]
http_response_code(428); echo 'Precondition Required'; exit;
res.writeHead(428, { 'Content-Type': 'text/plain' });
res.end('Precondition Required');
# in a view function return 'Precondition Required', 428
Change the paths to suit. In nginx, add_header needs always to apply to error responses.
Related codes
- 429Too Many RequestsThe client sent too many requests in a given time and is being rate limited.
- 426Upgrade RequiredThe server will only answer over a different protocol, named in the Upgrade header.
- 425Too EarlyThe server will not risk processing a request that might be replayed.
- 431Request Header Fields Too LargeThe headers are too big, either one header or all of them together.
All status codes · All 4xx codes
Names and numbers from the IANA HTTP Status Code Registry. Google Search behaviour as documented by Google Search Central.