Why my accidental 404 stuck around, and the 308 I should have used
Two HTTP status details bit me while building a reference page, and I still see them wrong in other people's APIs.
1. A 404 can be cached with no headers at all.
RFC 9110 section 15.1 lists the codes a cache may store without any Cache-Control or Expires: 200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414 and 501 (RFC 7725 adds 451). So if a deploy briefly serves a 404 for a page that exists, some cache can keep serving it after you fix the deploy. If an error is temporary, say so with headers.
2. 301 and 308 are not the same redirect.
- 301 and 302: a client may turn a POST into a GET.
- 303: always turns it into a GET.
- 307 and 308: must repeat the method and body exactly.
So a renamed page is a 301 with a Location header. A renamed API endpoint that takes POSTs should be a 308, otherwise your clients quietly stop sending the body.
Quick one on login errors. Failed login is 401, not 403. 401 means "I don't know who you are" and should carry a WWW-Authenticate header. 403 is for when you know who they are and still say no.
I built a small browser page that lists every registered code from 100 to 511 with when to send it, whether it's cacheable, and the RFC. It also has snippets for Express, Fastify, FastAPI, Go and PHP, so I'm biased. Nothing you type leaves the browser. Checked against sources on 8 Nov 2026:
Which code do you see misused most? For me it's 200 with an error in the body.
(I used an AI assistant to help draft this; the facts are from the page above.)