Every web request travels through a precise sequence of steps, DNS lookup, TCP handshake, TLS negotiation, HTTP exchange, and browser rendering. Understanding this chain is what separates engineers who debug network issues from engineers who guess.
webnetworkingbrowserhttpdnstcp
Curated Video Reference
YouTube
Hand-picked video lecture to deepen your understanding of How the Web Works: The Request Lifecycle
1. In what order does the browser check caches before making a network request?
Interview Questions
1 questions
Cheatsheet
Download-ready reference
Cheatsheet
DNS domain โ IP. Cold lookup: 20, 120ms. Warm: ~0ms.
Reduce with: dns-prefetch, preconnect, high TTL.
TCP 3-way handshake = 1 RTT. Keep-alive reuses connections.
HTTP/2 multiplexes all requests over one connection.
TLS 1.3 1 RTT (vs TLS 1.2's 2 RTT). 0-RTT resumption for returning users.
TTFB DNS + TCP + TLS + server time. Target: < 200ms.
Cache order memory cache โ service worker โ disk cache โ push cache โ network
Cache-Control
max-age=N browser (and CDN if public) caches for N seconds
s-maxage=N CDN cache duration (overrides max-age for shared caches)
immutable browser never revalidates (use only with content-hashed URLs)
no-cache revalidate every time (but can still return 304)
no-store never cache anything
private browser only, CDN must not cache
Script loading
<script> render-blocking (parser halts until downloaded + executed)
<script defer> executes after parse, in order, before DOMContentLoaded
<script async> executes as soon as downloaded, order not guaranteed
<script type=module> deferred by default
Hints
<link rel="preconnect"> resolve DNS + TCP + TLS early
<link rel="dns-prefetch"> resolve DNS only (lower priority)
<link rel="preload"> fetch resource early, don't execute yet
When you type https://example.com and press Enter, you trigger a chain of at least seven distinct steps before a single pixel appears. Knowing this chain cold is the baseline for debugging performance issues, security vulnerabilities, and production outages.
If a valid cached response exists, the lifecycle ends here. This is why Cache-Control: max-age=31536000, immutable on static assets is so powerful, the browser never hits the network.
DNS converts a hostname to an IP address. The lookup follows a strict hierarchy:
Browser DNS cache โ (miss)OS DNS cache (checked via /etc/hosts on Unix, registry on Windows) โ (miss)Router / ISP resolver โ (miss)Recursive resolver โ Root nameserver โ TLD nameserver โ Authoritative nameserver
A cold DNS lookup typically adds 20, 120ms. CDNs reduce this by placing authoritative nameservers close to users. dns-prefetch and preconnect hints let the browser resolve DNS early for known third-party origins.
TCP is connection-oriented, it guarantees ordered, reliable delivery. Before any data flows, a 3-way handshake establishes the connection:
Client โ SYN โ ServerClient โ SYN-ACK โ ServerClient โ ACK โ Server [connection established]Client โ HTTP request โ Server
This costs 1 full round-trip before the first byte of request data. At 100ms RTT, that's 100ms wasted just opening the connection. HTTP/1.1 keep-alive, HTTP/2 multiplexing, and HTTP/3's QUIC protocol all exist partly to amortize this cost.
TLS 1.3 reduces the handshake to 1-RTT (vs 2-RTT for TLS 1.2). TLS session resumption (0-RTT) can eliminate the handshake entirely for returning clients, though it carries replay-attack risk for non-idempotent requests.
With the connection established, the browser sends an HTTP request:
GET /api/data HTTP/2Host: example.comAccept: application/jsonAuthorization: Bearer <token>If-None-Match: "abc123" โ conditional request, might get 304 Not Modified
The server processes the request and returns a response with status, headers, and body. The Content-Type, Content-Encoding, and Transfer-Encoding headers govern how the browser reads the body.
1. Thinking a request only involves one round trip#
Every new origin requires DNS + TCP + TLS (3, 4 RTTs) before the first byte. A page that loads from 10 origins multiplies that cost. Use preconnect for critical third parties.
<!-- Tell the browser to resolve DNS + open a connection early --><link rel="preconnect" href="https://fonts.googleapis.com" /><link rel="dns-prefetch" href="https://analytics.example.com" />
2. Not understanding that HTTPS is not just "HTTP + security"#
TLS renegotiation, certificate validation, OCSP stapling, and cipher negotiation all add latency and CPU cost. This matters for time-to-first-byte (TTFB) analysis.
3. Confusing the browser cache with the CDN cache#
The browser cache is private (per-user). A CDN cache is shared (edge nodes). A Cache-Control: private response is not cached by CDNs. A Cache-Control: public response can be. Getting this wrong leads to authentication bypasses or stale content served to everyone.
HTTP/1.1 defaults to keep-alive, but some server configs close connections aggressively. HTTP/2 makes this moot, multiplexing means all requests share one connection per origin.
Third-party requests are opaque to PerformanceObserver. Without Timing-Allow-Origin: *, you can't see DNS/TCP/TLS breakdown for cross-origin resources in DevTools.
Minimize origins. Each new origin costs 3, 4 RTTs before the first byte. Self-host critical fonts and scripts.
Use HTTP/2 or HTTP/3. HTTP/2 multiplexing eliminates the per-resource connection cost. Verify your server supports it.
Add preconnect hints for known critical third-party origins (analytics, fonts, CDN).
Set cache headers deliberately. Immutable assets get max-age=31536000, immutable. HTML gets no-cache (revalidate every time). Never omit Cache-Control on static assets.
Measure TTFB. It directly reflects DNS + TCP + TLS + server processing. Anything above 200ms deserves investigation.
Use if your server supports it, it lets the browser preload critical resources while the server is still generating the HTML response.
Cold DNS adds 20, 120ms per new origin. Measure with performance.getEntriesByType("resource")[n].domainLookupEnd - .domainLookupStart.
TLS 1.3 + session resumption eliminates the TLS RTT for returning users. Verify on SSL Labs.
HTTP/2 server push has largely been abandoned (Chrome removed it). Use <link rel="preload"> instead.
Target TTFB < 200ms. If TTFB is high, the problem is server-side (DB queries, cold start), no amount of frontend optimization helps.
Connection coalescing in HTTP/2: if two domains resolve to the same IP and share a TLS certificate, the browser reuses one connection. CDN providers exploit this.