Lesson 4 of 18
3. Client and Server

3.3 What happens when you type a URL and press Enter?

3 min read+10 XP

In the restaurant: Before you eat, a lot happens. You find the restaurant's address, walk in and get a table, check it's the real restaurant and not a fake, order, the kitchen cooks, and you eat.

In the system: Typing https://shop.example.com/books/42 sets off six steps. This is one of the most common interview questions, and it touches half this book.

the six steps from pressing Enter to seeing the page.

Figure: the six steps from pressing Enter to seeing the page, and where each one is covered in this book.

  1. Find: the browser turns shop.example.com into an IP address using DNS (Chapter 4). It checks its own cache first.
  2. Connect: it opens a connection to that IP address on port 443, with a TCP handshake (3.7). With HTTP/3 it uses QUIC instead (3.9).
  3. Secure: a TLS handshake checks the server's certificate and agrees on encryption keys (3.8).
  4. Ask: the browser sends the HTTP request GET /books/42 (3.4).
  5. Answer: the request usually reaches a load balancer (Chapter 7), then an app server, which may check a cache (Chapter 12) and the database (Chapter 8). The server sends back a response.
  6. Show: the browser reads the HTML and starts rendering. It discovers more things it needs (CSS, JavaScript, images) and requests those too, often from a CDN (Chapter 26).

In an interview, say the steps in order, then go deep wherever the interviewer points.

Memory code: "Few Cooks Serve All And Smile." Find, Connect, Secure, Ask, Answer, Show.