412 vs 428: Precondition Failed vs Precondition Required
412 and 428 can look similar in logs, but they tell clients, crawlers, and API consumers different things.
| Aspect | 412 | 428 |
|---|---|---|
| Meaning | Precondition Failed describes how the server processed the request and what the client should do next. | Precondition Required describes how the server processed the request and what the client should do next. |
| Typical use case | HTTP 412 Precondition Failed indicates a client errors response outcome. | HTTP 428 Precondition Required indicates a client errors response outcome. |
| Caching/client behavior | Check cache headers and downstream behavior for 412. | Check cache headers and downstream behavior for 428. |
| SEO implications | Search crawlers interpret 412 according to client-errors semantics. | Search crawlers interpret 428 according to client-errors semantics. |
| API/backend impact | API clients may branch logic specifically on 412. | API clients may branch logic specifically on 428. |
When to use one vs the other
Use 412 when the response should communicate precondition failed behavior; use 428 when precondition required is the accurate protocol signal.
A frequent mistake is swapping 412 and 428 for convenience; that causes client retry bugs, incorrect cache signals, and misleading monitoring data.
Decision summary: if user agents should receive the Precondition Failed signal, return 412; if they should receive Precondition Required, return 428.
FAQ
What is the biggest difference between 412 and 428?
412 communicates Precondition Failed, while 428 communicates Precondition Required. Choosing the right one keeps clients and intermediaries predictable.
Do 412 and 428 have SEO or caching impact?
Yes. Search engines and caches interpret status classes differently. Use each code according to its semantics to avoid accidental indexing, stale responses, or crawl inefficiency.
Can APIs safely return 412 instead of 428?
Only when it matches contract semantics. API clients often branch logic by exact code, so swapping them can break retries, auth handling, or user-facing errors.
Related guides: 412 Precondition Failed ยท 428 Precondition Required