AES Encryption Explained: How It Works and Why It Matters
Jun 23, 2026
4xx Client Error
The 412 (Precondition Failed) status code indicates that one or more conditions given in the request header fields evaluated to false when tested on the server. This is used with conditional requests using headers like If-Match, If-None-Match, If-Modified-Since, or If-Unmodified-Since.
When updating a resource, include the ETag of the current version in the If-Match header. If another client has modified the resource since the ETag was generated, the server returns 412 Precondition Failed, preventing the overwrite. The client must fetch the latest version and retry.
// Laravel - conditional update with If-Match
$post = Post::findOrFail($id);
$etag = md5($post->updated_at->timestamp);
if ($request->header('If-Match') !== '"' . $etag . '"') {
return response()->json([
'error' => 'Precondition Failed',
'current_etag' => $etag,
], 412);
}
Mistake: Confusing 412 (precondition failed) with 409 (conflict)
Fix: Use 412 when a conditional header (If-Match, If-Unmodified-Since) explicitly fails. Use 409 when the request conflicts with the resource state but no conditional header was involved.
Mistake: Not providing the current ETag in the 412 response
Fix: Include the current ETag or timestamp in the 412 response so the client can update its local state and retry the request with the correct precondition header.
Blog
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026