What this page is for

Intent: answer “What happens when you type a URL and press Enter?” step by step, in the order interviewers expect.
You’ll learn: the ten steps from URL to page on screen · what a round trip costs · why a second visit is faster · the questions that follow.
Time: about 8 minutes. Every step has a longer version on the detailed request lifecycle page.

Words you need first

  • URL (Uniform Resource Locator): the address you type, such as https://shop.com/cart. It has a scheme (https), a host (shop.com), an optional port (443 is the default for https) and a path (/cart).
  • DNS (Domain Name System): the internet’s phone book. It turns a name like shop.com into an IP address like 203.0.113.10. Networks route by IP address, never by name.
  • TCP (Transmission Control Protocol): the way two computers open a reliable pipe. Bytes arrive in order, and lost bytes are sent again.
  • TLS (Transport Layer Security): the layer that encrypts the pipe, proves the server really is shop.com, and detects tampering.
  • HTTP (HyperText Transfer Protocol): the language of the web. A request asks for something, and a response carries the answer.
  • Round trip (RTT): one message going to the other side and one coming back. If the path takes 50 milliseconds each way, one RTT is 100 milliseconds.
  • Cache: a stored copy kept so the browser does not have to ask again.

Why it exists

A browser starts with a name, shop.com. Networks route packets to IP addresses, not names, so the name must become an address first. Then a reliable pipe must be opened, because a page is too big to send as loose packets. That pipe crosses networks run by other people, so it must be encrypted and the server’s identity checked. Only then can the browser ask for the page.

The picture

Ten steps from typing a URL to the page on screen, stacked from top to bottom

Ten steps, top to bottom. Each one waits for the step above it.

How it works, with an example

Simply: Typing a web address is a chain of steps, like ordering a delivery: look up the address (DNS), open a phone line (TCP), lock it and check the shop (TLS), then ask for the item (HTTP).

What to know: You type https://shop.com/cart and press Enter. The browser reads the URL and has no fresh copy of the page. It asks DNS for the address of shop.com and gets 203.0.113.10. It opens a TCP pipe to that address, which takes 1 round trip. It runs TLS over the pipe, which takes 1 more, and checks that the certificate names shop.com. It sends GET /cart over the secure pipe, and the server answers 200 OK with the HTML one round trip later. The browser then fetches the files the HTML names and draws the page.

Added up, a first visit costs about 4 round trips: DNS 1, TCP 1, TLS 1, HTTP 1.

The most common mistake

One request is not one page

Many people say “the browser sends a request and gets the page.” The page is the end of a long chain. DNS, TCP and TLS come first. And the HTML is only the start: each stylesheet, script and image is another request. A normal page makes many requests, often dozens.

The steps one by one

Simply: Think of a checklist at a shop counter. Each step waits for the one before, from reading the order to laying out the goods.

What to know:

  1. Parse the URL. The browser splits it into scheme, host, port and path. For https with no port, it uses 443. No network traffic yet.
  2. Check the browser cache. If it holds a fresh copy of the page, it shows that copy and skips the rest. See HTTP caching.
  3. DNS lookup. The browser checks its own DNS cache, then asks a recursive resolver (a DNS helper that does the searching). The answer is kept for its TTL (time to live, how many seconds it may be reused). A cached answer costs about 1 round trip. See DNS.
  4. TCP connection. The browser sends SYN, the server answers SYN-ACK, and the browser sends ACK. This three-message handshake opens the pipe and costs 1 round trip. No page data moves before it. See TCP.
  5. TLS handshake. The two sides agree on keys, and the browser checks the server’s certificate. In TLS 1.3 this costs 1 round trip. See TLS.
  6. Send the HTTP request. The browser sends GET /cart HTTP/1.1 with headers such as Host and Accept, encrypted by TLS. See HTTP message.
  7. Server work. A load balancer, a machine that spreads requests over many identical servers, picks one app server. The app runs its code and often asks a database for data.
  8. HTTP response. The server sends 200 OK, headers such as Cache-Control (how long to keep the copy), and the HTML. It arrives 1 round trip after the request.
  9. Sub-resources. The HTML names more files: CSS, JavaScript, images and fonts. Each is a new request, often sent over the open connection.
  10. Render. The browser builds the DOM (the page’s structure) and the CSSOM (its styles), works out where each box goes, paints the pixels, and runs the JavaScript.

Second visit: what gets skipped

Simply: A second visit skips much of the first visit’s work. The browser often still has the address, the open line, and a saved copy.

What to know:

  • DNS. The answer is still cached until its TTL runs out, so no query is needed.
  • TCP and TLS. If the pipe is still open, the browser reuses it.
  • HTTP. A fresh cached copy is shown with no network traffic. A stale copy is checked, and the server may answer 304 Not Modified with no body. That check still costs 1 round trip.
StepFirst visitSecond visit
DNS1 RTT or moreskipped (cached)
TCP1 RTTskipped if the pipe is open
TLS1 RTTskipped if the pipe is open
HTTP1 RTT0 if fresh, 1 RTT if checked
Totalabout 4 RTTabout 1 RTT, or 0 if fresh

Say it in an interview

“I’d walk the path in order. The browser parses the URL and checks its cache. On a miss, DNS turns the host into an IP address. TCP opens a connection with a three-way handshake, one round trip. TLS encrypts it and checks the certificate, one more round trip in TLS 1.3. Then the HTTP request goes out, a load balancer picks a server, and the app answers. The browser fetches the CSS, scripts and images, and renders the page. A first visit costs about four round trips. A second visit usually skips DNS and the handshakes.”

Questions interviewers ask

Tap a question to see the answer.

Mental map

Request lifecycle mental map

Watch

ByteByteGo, short video: the whole journey from typing a URL to the page on screen, with DNS, TCP, TLS and HTTP.

Want more? The detailed request lifecycle page has the same sections with raw messages, exact round-trip math, and more interview questions.


← HTTP message · DNS →