What happens when you type a URL and press Enter?
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 of 5
Browser cache and DNS resolution
Before any network traffic, the browser checks its own HTTP cache. On a miss the query reaches a recursive resolver, which checks its own cache; only when that misses does a DNS lookup run: root servers point to the TLD servers, the TLD points to the authoritative nameserver, and the authoritative server returns the IP. Watch the query walk the hierarchy — each hop is a chance to answer from cache instead.
Animation — Browser cache and DNS resolution
recursive cache
Browser cache miss — the hostname is unknown locally.
Edge cases & traps
- DNS cache poisoning / low TTL: a low TTL means more lookups but faster failover — interviewers like the trade-off.
- TLS session resumption: the second visit can skip the full handshake via session tickets.
- HTTP/2 multiplexing: one connection carries many requests, so the old "6 connections per host" limit disappears.
- Parser-blocking scripts: a sync <script> in <head> delays first paint — mention defer/async.
- Service workers can intercept the request entirely and answer from cache before DNS is ever consulted.