HTTP deep dive
Methods and their idempotency guarantees, status-code semantics, headers, keep-alive, timeouts. PUT vs PATCH vs POST is a real interview question with a real answer.
The mental model
HTTP is a **postal system with a very strict envelope format**. Every message is an envelope: a line saying what you want (GET /orders/42 HTTP/1.1), a stack of labelled slips (headers) describing the contents and how to handle them, a blank line, and optionally the parcel itself (the body). The reply comes back in the same shape: a status line, headers, blank line, body. That is the entire protocol. Everything else — REST, GraphQL over HTTP, gRPC-Web, webhooks — is a convention layered on those envelopes.
The part people skip, and the part interviews actually probe, is the **semantics attached to the verbs and codes**. HTTP is not a dumb pipe; it makes promises. GET promises to be safe (no observable state change), so any proxy, browser, or crawler in the world may issue it, repeat it, and cache it. PUT and DELETE promise to be idempotent, so a retry after a timeout is safe. POST promises nothing, which is why every retried POST is a potential duplicate charge.
**What breaks without this knowledge.** A team makes GET /orders/42/cancel because it was easy to hit from a browser — and a link prefetcher cancels orders. A mobile client's request times out at 5 s while the server was still processing; the client retries the POST, and the customer is charged twice. A service returns 200 OK with {"error": "not found"} in the body, so the client's retry logic, the CDN, and every dashboard treat a failure as a success. A load balancer with a 60 s idle timeout sits in front of an application with a 30 s keep-alive timeout, and users see random connection resets that nobody can reproduce. Every one of these is an HTTP semantics bug, not a code bug.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision