What Is a 412 Status Code?
One or more conditions given in the request header fields evaluated to false when tested on the server.
This response code allows the client to place preconditions on the current resource state (its current representations and metadata) and, thus, prevent the request method from being applied if the target resource is in an unexpected state.
- Source: RFC7232 Section 4.2
412 CODE REFERENCES
Rails HTTP Status Symbol
Go HTTP Status Constant
Symfony HTTP Status Constant
Python2 HTTP Status Constant
Python3+ HTTP Status Constant
Python3.5+ HTTP Status Constant
When is a 412 status code used?
An HTTP 412 status code is used for HTTP requests are not HTTP method HEAD or HTTP method GET.
When the 412 precondition failed error message is received, the client will know that one or more of the conditions in the request has failed and the resource will not be retrieved in the expected format or state.
Will search engines index a URL with a 412 status code?
No. Search engines like Google will not index a URL with the HTTP 412 precondition failed status code. That means that URLs that have been previously indexed but are now returning a 412 response status will likely suffer a loss in their search result rankings.
412 status code example
Want to see a 412 response code in action? Check out the 412 example below. In this example, the client is requesting to leave a comment on an article but only wants their response to be recorded if the article hasn’t been updated since they last viewed it.
If this article has been modified, the server will respond with a 412 precondition failed status error to demonstrate that the client’s request hasn’t been fulfilled.
POST /examplearticle/update?postid=123&task=reply HTTP/1:1
If-unmodified-since: 13 March 2023 0:00:00 GMT
Content length: 30
<message body from client>
HTTP/1:1 412 Precondition Failed
Content type: text/plain
Content length: 60
<title> Article Update Error <title>
<p> This article has been updated since you recorded your comment, so your response will not be posted.<>;p>
Which browsers are compatible with a 412 response code?
The following browsers will issue an HTTP 412 response code:
- Google Chrome
- Microsoft Edge
- Chrome Android
- Safari on iOS
- Samsung Internet
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs