CN/Lesson 7 of 8/5 min read
What Happens When You Type a URL
The full journey of a web request from URL parsing through DNS, ARP, TCP, TLS, HTTP, server processing, and browser rendering, tying every layer together.
On this page
The most famous networking interview question. Use it to show you understand every layer. Example: you type https://www.example.com/products and press Enter.
1. URL parsing
The browser parses the URL (Uniform Resource Locator):
https:// www.example.com :443 /products ?page=2 #reviews
scheme host port path query fragment- If the text is not a valid URL, the browser treats it as a search query.
- The HSTS preload list is checked: if the domain is on it, the browser uses HTTPS even if you typed
http://. - Non-ASCII domain names are converted to Punycode.
- The fragment (
#reviews) is never sent to the server.
2. Cache checks
Before any network traffic, the browser checks:
- Service worker that may answer the request.
- HTTP cache: a fresh cached response (
Cache-Control: max-age) is used directly. - An existing open connection to the same origin (connection pooling).
3. DNS resolution
To find the server's IP address (details in DNS):
- Browser DNS cache, then OS cache, then the
hostsfile. - Query to the recursive resolver (UDP 53, or DoH).
- Resolver walks root,
.comTLD, thenexample.com's authoritative server (unless cached). - Answer:
www.example.comCNAME to a CDN name, which resolves to an A/AAAA record like93.184.216.34. With a CDN, this IP is usually a nearby edge server.
4. Getting the packet out: ARP and routing
The destination is not on the local network, so the host sends the packet to its default gateway:
- The OS checks its routing table: destination is off-subnet, so the next hop is the gateway (e.g.
192.168.1.1). - It needs the gateway's MAC address: ARP cache, or an ARP broadcast (see ARP).
- The frame goes to the home router, which performs NAT (rewrites the private source IP:port to its public one).
- The packet hops across ISP routers. Each router does a longest prefix match; across ISPs, paths are chosen by BGP (see routing). TTL decrements at each hop.
5. TCP connection
The browser opens a TCP connection to port 443 with the three-way handshake: SYN, SYN-ACK, ACK (see TCP). Costs one RTT.
With HTTP/3, the browser instead uses QUIC over UDP, combining transport and crypto setup.
6. TLS handshake
For HTTPS, a TLS 1.3 handshake follows (1 RTT, 0 RTT on resumption):
- ClientHello: supported TLS versions, cipher suites, a key share (ECDHE), and SNI (Server Name Indication: which host it wants, since one IP can host many sites), plus ALPN (
h2orhttp/1.1). - ServerHello: chosen cipher, server key share. From here, everything is encrypted.
- Server sends its certificate chain and a signature proving it holds the private key.
- The browser validates the certificate: chain to a trusted root CA, hostname matches, not expired, not revoked (OCSP stapling / CRLs), Certificate Transparency.
- Both sides derive symmetric session keys from the Diffie-Hellman exchange (forward secrecy). Finished messages confirm integrity.
Details: TLS and certificates.
7. HTTP request
The browser sends the request over the encrypted channel:
GET /products HTTP/2
Host: www.example.com
Accept: text/html
Accept-Encoding: gzip, br
Cookie: session=...
User-Agent: ...8. Server side
On the server's end:
- CDN edge may serve a cached response directly.
- Otherwise a load balancer picks a healthy backend server (see load balancing). TLS is often terminated here.
- A reverse proxy / web server (Nginx) routes to the application server.
- The application runs: authenticates the session, checks a cache (Redis), queries the database if needed, renders HTML or JSON.
- The response travels back with status code, headers (
Content-Type,Cache-Control,Set-Cookie), and a compressed body.
9. Browser rendering
Critical Rendering Path
The critical rendering path is the sequence of steps from bytes to pixels:
- Parse HTML into the DOM tree. On
<script>withoutasync/defer, parsing pauses to download and run it. - Parse CSS into the CSSOM.
- Combine into the render tree (only visible elements with computed styles).
- Layout (reflow): compute size and position of every element.
- Paint: fill pixels for text, colors, images, borders.
- Composite: combine layers on the GPU and display.
Subresources (CSS, JS, images, fonts) trigger more requests, reusing the same connection thanks to HTTP/2 multiplexing. JavaScript runs on the main thread and can modify the DOM, causing more layout and paint. The page becomes interactive when the main thread is free to respond to input.
10. After loading
- Connection kept alive for future requests, then closed (FIN handshake) after idle time.
- Cookies stored; resources cached according to headers.
- Analytics, prefetching and service worker registration may run in the background.
Layer summary
| Layer | What happened |
|---|---|
| Application | URL parsing, DNS, HTTP, TLS |
| Transport | TCP handshake (or QUIC), ports 443 and ephemeral |
| Network | IP routing, NAT, BGP, TTL |
| Data link | ARP for the gateway MAC, Ethernet/Wi-Fi frames, switches |
| Physical | Bits over copper, fiber, radio |
Quick revision
- Order: parse URL, caches, DNS, ARP to gateway, TCP, TLS, HTTP, server (CDN, LB, app, DB), response, render.
- SNI tells the server which certificate to use.
- Rendering: DOM + CSSOM, render tree, layout, paint, composite.