What happens when you type a URL and press Enter?
Company tags are compiled from public interview reports and are signals, not guarantees.
What interviewers are testing
Interviewers use this to map the boundary of your knowledge. Anyone can say "DNS then HTTP"; strong candidates can narrate caching layers, connection setup, and rendering without hand-waving. It also reveals whether you understand the web as a system rather than a stack of unrelated buzzwords.
Mental model
Think of it as a delivery pipeline: resolve the address (DNS), open a secure lane (TCP + TLS), place the order (HTTP), then assemble the package (parsing, layout, paint). Every stage has a cache that can short-circuit the previous stage.
Step-by-step solution
Step 1: Browser cache and DNS resolution
Before any network traffic, the browser checks its own HTTP cache and the operating system checks its DNS cache; only on a miss does the query reach a recursive resolver, which checks its own cache before leaving the machine. Every cache miss then walks the hierarchy: a root server delegates to the TLD servers for .com, the TLD delegates to the domain’s authoritative nameserver, and the authoritative server returns the A/AAAA record. Each answer carries a TTL, so the very next lookup can short-circuit at any hop — the full hierarchy walk happens only once per TTL. Watch the packets: every arrow is a round trip that caching can eliminate. DNS usually runs over UDP because a query fits in one packet; TCP takes over for large responses and zone transfers.
Step 2: TCP handshake
The browser opens a TCP connection with the three-way handshake: the client sends SYN with a random sequence number, the server answers SYN-ACK acknowledging it and offering its own, and the client ACKs back. Both sides now agree the channel works in both directions and share initial sequence numbers. That costs one full round trip — roughly 10-150 ms depending on distance — before a single byte of HTTP is sent. Real pages amortize it: keep-alive reuses the socket for many requests, and TCP Fast Open can shave a round trip off repeat connections. This RTT tax is exactly why HTTP/3 dropped TCP for QUIC over UDP, where transport and crypto handshakes fuse into one round trip.
Step 3: TLS handshake
Because the URL is HTTPS, a TLS handshake wraps the raw TCP stream. The client sends ClientHello with its supported cipher suites, TLS version, a random nonce, and the SNI hostname so the server can choose the right certificate before any encryption exists. The server replies with its certificate chain and proves it holds the matching private key; the client validates the chain against trusted roots, checks the hostname, and rejects anything expired or mis-issued. Both sides then perform an ephemeral ECDHE exchange — the shared secret never travels — and derive the same session keys; a Finished exchange proves the handshake was not tampered with. TLS 1.3 finishes in one round trip, and session resumption (tickets or PSK) lets returning visitors skip most of it.
Step 4: HTTP request and response
The browser sends an HTTP request: method and path, then headers like Host, Accept, Accept-Encoding, and the cookies for that domain. It usually hits a CDN edge first, which answers from cache on a hit or forwards to an origin behind a load balancer on a miss; the app queries its data stores and returns a status code, headers, and a body. Compression (br or gzip) shrinks the transfer, and caching headers decide whether the next visit needs this trip at all: Cache-Control max-age lets the browser skip the network, while an ETag enables a cheap 304 Not Modified revalidation. Watch the request make the full round trip — the response headers are why the second visit is nearly free.
httpGET / HTTP/2 Host: example.com Accept: text/html,application/xhtml+xml Accept-Encoding: br, gzip Cookie: session=abc123 HTTP/2 200 OK Content-Type: text/html; charset=utf-8 Content-Encoding: br Cache-Control: public, max-age=600 ETag: "a1b2c3"
Step 5: Parsing, layout, paint
While the HTML streams in, a preload scanner keeps fetching images, fonts, and scripts in parallel, so the tokenizer is not the only thing working. Tokens build the DOM; CSS builds the CSSOM; DOM and CSSOM combine into the render tree of visible nodes; layout computes exact geometry for every box; paint records draw calls; the compositor stitches layers on the GPU. CSS is render-blocking — the browser refuses to paint before the CSSOM exists, which is why critical CSS is inlined and the rest deferred. A synchronous <script> in the head blocks the parser until it executes; defer and async load it without stopping parsing. After first paint, the framework hydrates the server-rendered HTML and attaches event listeners.
Edge cases & traps
- Cache-Control: max-age skips the network entirely, no-store forbids caching, and ETag adds a conditional 304 path — know which one the response asks for.
- DNS TTL is a trade-off: a low TTL makes failover fast but multiplies lookups; a long TTL is faster until the record changes.
- HTTP/2 multiplexes many requests over one connection, so the old "6 connections per host" limit disappears — do not cite it as a current limit.
- Render-blocking CSS and synchronous scripts delay first paint: inline critical CSS, defer the rest, and preload what the first screen needs.
- Service workers can answer from cache before DNS is ever consulted; preconnect and dns-prefetch warm connections during idle time.