3. Client and Server
1
The picture to keep in your head2
3.1 What exactly are a client and a server?3
3.2 What's a request and a response?4
3.3 What happens when you type a URL and press Enter?5
3.4 What do GET, POST, PUT, PATCH and DELETE mean?6
3.5 What do status codes tell you?7
3.6 What goes in the headers and what goes in the body?8
3.7 What's the difference between TCP and UDP?9
3.8 How does HTTPS keep the conversation private?10
3.9 Why do keep-alive, HTTP/2 and HTTP/3 make things faster?11
3.10 What does "stateless" mean, and why do we want it?12
3.11 How do cookies, sessions and tokens remember who you are?13
Memory card and where the analogy breaks14
Practice: five levels15
Interview questions16
Solutions17
Sources18
Code lab3. Client and Server
Memory card and where the analogy breaks
3 min read+10 XP
The memory card (tear this page out)
| # | Question | Memory code |
|---|---|---|
| 3.1 | Client and server? | Customers ask, kitchens cook |
| 3.2 | Request and response? | One slip, one plate. Nothing is served that wasn't ordered. |
| 3.3 | Typing a URL? | Few Cooks Serve All And Smile: Find, Connect, Secure, Ask, Answer, Show |
| 3.4 | HTTP methods? | GET looks, POST adds, PUT replaces, PATCH tweaks, DELETE removes |
| 3.5 | Status codes? | 2 is good, 3 go elsewhere, 4 your fault, 5 our fault |
| 3.6 | Headers and body? | Headers describe, body delivers |
| 3.7 | TCP vs UDP? | TCP confirms, UDP fires and forgets |
| 3.8 | HTTPS? | Check the badge, then seal the envelope |
| 3.9 | Keep-alive, HTTP/2, HTTP/3? | Keep the waiter, fill the tray, don't stop for one dropped plate |
| 3.10 | Stateless? | Every slip says it all |
| 3.11 | Cookies, sessions, tokens? | Session: we keep the notebook. Token: you carry the stamped card. |
The whole chapter in one line: The customer always orders first, the slip says everything, and the envelope is sealed.
Where the analogy breaks
- A waiter serves a few tables. A server handles thousands of requests at the same time, from people who never see each other.
- A restaurant has one kitchen. A website usually has many identical servers behind a load balancer, which is exactly why statelessness matters.
- Waiters don't need a handshake before every table. Networks do, and those round trips are a real cost you design around.
Quick check
Five questions on this chapter. Pick an answer, then check it.
quiz