HTTP 308 Permanent Redirect vs 412 Precondition Failed
HTTP 308 (Permanent Redirect) is a 3xx Redirection response, while 412 (Precondition Failed) is a 4xx Client Error response. 308 indicates that the resource has been permanently moved. Like 301, but guarantees the HTTP method will NOT be changed. In contrast, 412 means that one or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
Description
The resource has been permanently moved. Like 301, but guarantees the HTTP method will NOT be changed.
When You See It
For permanent URL changes where POST requests must remain POST.
How to Fix
Update all references to the new URL. The HTTP method is preserved.
Description
One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
When You See It
When using conditional requests with ETags and the resource has changed.
How to Fix
Refresh the ETag/Last-Modified value and retry with updated preconditions.
Key Differences
308 is a 3xx Redirection response, while 412 is a 4xx Client Error response.
HTTP 308: The resource has been permanently moved. Like 301, but guarantees the HTTP method will NOT be changed.
HTTP 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
You encounter 308 when for permanent URL changes where POST requests must remain POST.
You encounter 412 when when using conditional requests with ETags and the resource has changed.
When to Use Which
For 308 (Permanent Redirect): Update all references to the new URL. The HTTP method is preserved. For 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions.