← 速查表

HTTP 状态码速查表

每个 HTTP 响应都带一个三位状态码。第一位表示类别:1xx 信息、2xx 成功、3xx 重定向、4xx 你这边出错、5xx 服务器出错。

2xx — 成功

状态码名称什么时候见到
200OKStandard success — page loaded, GET returned data
201CreatedPOST created a resource (new record, uploaded file)
204No ContentSuccess with an empty body — common for DELETE

3xx — 重定向

状态码名称什么时候见到
301Moved PermanentlyURL changed for good; browsers and search engines cache it
302FoundTemporary redirect — do not use for moved content
304Not ModifiedClient cache is still valid; body not resent

4xx — 客户端错误

状态码名称什么时候见到
400Bad RequestMalformed syntax — invalid JSON, bad parameters
401UnauthorizedNot authenticated (no/invalid credentials) — log in first
403ForbiddenAuthenticated but not allowed — do not retry as-is
404Not FoundNo resource at this URL
409ConflictRequest contradicts current state (duplicate, version clash)
422Unprocessable EntityWell-formed but semantically invalid (validation failed)
429Too Many RequestsRate limit hit — back off, honor Retry-After

5xx — 服务端错误

状态码名称什么时候见到
500Internal Server ErrorUnhandled exception on the server — check the logs
502Bad GatewayUpstream service returned garbage or died
503Service UnavailableOverloaded or in maintenance — usually temporary
504Gateway TimeoutUpstream took too long to answer

常见问题

401 vs 403 — both mean "no", right?
401 = "who are you?" (missing or invalid authentication). 403 = "I know who you are and you still can't". Retrying 403 with the same credentials never helps.

301 vs 302 for SEO?
301 passes ranking signals to the new URL and browsers cache it aggressively. Use 302 only when the move is truly temporary — search engines keep the old URL indexed.

I got a 429 — what now?
Slow down. Read the Retry-After header if present, add exponential backoff, and batch requests. Hammering a rate-limited endpoint turns 429 into 403.