132 HTTP status codes and headers
What 404 and 500 actually mean, and what Content-Type or Cache-Control do — one line each.
Status codes
1xx Informational4
A progress note; the real answer follows.
2xx Success10
The request went through.
3xx Redirection7
Go somewhere else — the distinction is permanent versus temporary.
4xx Client error29
The problem is on the request side; sending the same thing again will fail again.
5xx Server error11
The problem is on the server side; retrying later is often worth it.
Headers
Request headers28
Headers the browser attaches when it sends to the server.
Response headers30
Headers the server attaches when it answers.
Both directions13
Headers that can appear on either side.
How to read this
- The first digit of a status code carries the meaning: 4 means the request, 5 means the server.
- 404 means "not there"; 403 means "there, but not for you". Swapping them makes debugging slower.
- Header names are case-insensitive — Content-Type and content-type are the same header.
- Caching and CORS problems usually come down to one header line, visible in the browser’s network tab.
Frequently asked questions
Q. What is the difference between 404 and 403?
404 says nothing is at that address; 403 says something is, but you may not see it. Some servers deliberately answer 404 to hide the fact that a resource exists at all.
Q. Can I do anything about a 500?
Codes starting with 5 are the server’s problem, so usually only waiting helps. A 502 or 504 sits between a front and back server, though, and often clears on a retry a moment later.
Q. How do I choose between 301 and 302?
Use 301 when the address has moved for good and 302 when it is temporary. Remember that browsers and search engines remember a 301 for a long time, which makes it hard to undo.
Q. Are header names case-sensitive?
No. Content-Type and content-type are the same header, and since HTTP/2 they are sent lowercase by definition.
Q. Why do CORS errors happen?
When a page tries to read a response from another origin, the browser blocks it unless the server allowed it with Access-Control-Allow-Origin. The server did answer — the browser simply refuses to hand the body to your code, which is why the network tab shows a response your script cannot read.