← Back to Home

🌐 What Happens When You Type a URL

DNS from the root servers to Route 53, TCP, TLS 1.3 with a real certificate chain, HTTP/2, caching and rendering, measured live against this very site.

You type learn.ytamang.com into the address bar and press Enter. About a quarter of a second later, a page appears. In that quarter second, your computer asks a chain of DNS servers on three continents where the site lives, opens a TCP connection to a machine in Germany, agrees on encryption keys with it, checks a chain of four certificates, speaks HTTP/2, and hands about 15 KB of HTML to a rendering engine that turns it into pixels.

This is one of the most famous interview questions in software, because the answer touches almost everything: networking, cryptography, operating systems, browsers and servers. This article answers it properly, with real measurements of this very site taken from a laptop in Europe.

How to read this: every section is one stage of the journey. Each one says what happens, shows you the real output, and names the tool you can use to see it yourself. The stages tie together several other tutorials on this site: DNS and Route 53, P vs NP (the maths behind TLS), and Thinking Like a Systems Engineer (the same journey, seen from inside the server).

The Whole Journey at a Glance

Step through the journey

  1. Parse the input. Is it a URL or a search? The browser adds https:// and checks its HSTS list.
  2. Check caches. Browser DNS cache, OS cache, maybe a Service Worker that can answer without the network at all.
  3. DNS lookup. The stub resolver asks a recursive resolver, which walks root β†’ .com β†’ Route 53 and returns 5.75.145.2.
  4. TCP handshake. SYN, SYN-ACK, ACK: one round trip (about 53 ms) to Germany.
  5. TLS 1.3 handshake. ClientHello with SNI and ALPN, ServerHello, a 4-certificate chain, keys agreed with X25519: one more round trip.
  6. HTTP/2 request. GET / with headers, compressed with HPACK, sent on stream 1.
  7. Server work. nginx maps the Host to a directory, reads index.html (likely from the page cache) and sends 15 KB, gzipped to 4.7 KB.
  8. Response arrives. Status 200, headers, body. The browser stores the ETag for next time.
  9. Parse and build the DOM. The HTML is tokenised into a tree; CSS and JS references trigger more requests on the same connection.
  10. Style, layout, paint, composite. The render pipeline turns the DOM and CSSOM into pixels on your screen.

The real timings for this site, measured with curl from a laptop about 53 ms away from the server:

$ curl -s -o /dev/null -w 'dns=%{time_namelookup} tcp=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total} http=%{http_version}\n' https://learn.ytamang.com/
dns=0.041517 tcp=0.110152 tls=0.181512 ttfb=0.232728 total=0.284517 http=2
   0 ms        41 ms           110 ms               182 ms          233 ms   285 ms
   │── DNS ─────│──── TCP ───────│────── TLS ──────────│── request ─────│─ body ─│
   β”‚  resolver  β”‚ SYN / SYN-ACK  β”‚ ClientHello …       β”‚ GET / β†’        β”‚ 15 KB  β”‚
   β”‚  lookup    β”‚  (1 RTT)       β”‚ Finished (1 RTT)    β”‚ ← first byte   β”‚        β”‚

Every number is a cumulative timestamp. The thing to notice is that almost all of the time is round trips, not computation. The ping time to the server is 53 ms, and the page needs about four round trips before the last byte arrives. That one fact explains most of web performance engineering.

Step 1: The Browser Interprets What You Typed

The address bar doesn't know if learn.ytamang.com is a website or a search query. Browsers use heuristics: it contains a dot and no spaces, and .com is a known top-level domain, so it's treated as a hostname.

Then the browser has to choose http:// or https://. Modern browsers try HTTPS first by default ("HTTPS-First" mode in Chrome, HTTPS-Only in Firefox). Older behaviour, still visible with curl, is to go to plain HTTP and get redirected:

$ curl -sI http://learn.ytamang.com/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.24.0 (Ubuntu)
Location: https://learn.ytamang.com/

That redirect costs a full extra round trip (and a plaintext connection that could be tampered with). The fix is HSTS, the Strict-Transport-Security header: once a browser sees it, it rewrites every future http:// request to https:// internally, before anything touches the network. Sites can also be hard-coded into the browser's HSTS preload list, which protects even the very first visit.

Pro tip: this site doesn't send an HSTS header yet. You can check any site with curl -sI https://site | grep -i strict. A typical value is max-age=31536000; includeSubDomains.

The browser also parses the URL into parts. Every part has a job:

   https://learn.ytamang.com:443/0016-p-vs-np/?ref=home#quiz
   β””β”€β”¬β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜β””β”¬β”˜β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”¬β”€β”€β”€β”˜β””β”€β”¬β”˜
  scheme         host      port     path        query  fragment
  (protocol)  (DNS name)  (implied  (sent to    (sent to (NEVER sent:
                           by https) server)    server)  browser only)

Step 2: Caches Before the Network

Before doing any network work, the browser checks whether it already knows the answer:

Cache What it holds How to inspect
Service Worker Whole responses, under the site's control DevTools β†’ Application β†’ Service Workers
HTTP cache (memory / disk) Responses with their Cache-Control, ETag, Last-Modified DevTools β†’ Network β†’ "Size" column says (memory cache)
Browser DNS cache Recent hostname β†’ IP answers chrome://net-internals/#dns
OS resolver cache systemd-resolved, macOS mDNSResponder resolvectl statistics
Connection pool Already-open TCP+TLS connections to the host DevTools β†’ Network β†’ "Connection ID" column

This site registers a Service Worker (sw.js) that caches every tutorial page. On a repeat visit it can answer from the cache with no network at all, which is why the site works offline. The rest of this article follows the first visit, when every cache is cold.

Step 3: DNS, Turning a Name into an Address

Computers route packets by IP address, not by name, so the first network job is DNS resolution: learn.ytamang.com β†’ 5.75.145.2.

Who does the work

Your browser asks the operating system (getaddrinfo()). The OS reads /etc/nsswitch.conf (hosts: files dns), checks /etc/hosts, then sends a query to the recursive resolver listed in /etc/resolv.conf. That resolver might be your router, your ISP, or a public service such as 1.1.1.1 or 8.8.8.8. It's the resolver that does the real walk through the DNS hierarchy.

$ dig learn.ytamang.com A +noall +answer +stats
learn.ytamang.com.  256 IN  A   5.75.145.2
;; Query time: 46 msec
;; SERVER: 10.255.255.254#53(10.255.255.254) (UDP)

The walk, done by hand

To see what the recursive resolver does, we can do it ourselves by asking each level directly with +norecurse ("don't do the work for me, just tell me what you know"). DNS is a tree read from right to left: the root (.), then com., then ytamang.com., then learn.ytamang.com..

Ask a root server (a.root-servers.net, 198.41.0.4). It doesn't know the answer, but it knows who runs .com:

$ dig @198.41.0.4 learn.ytamang.com A +norecurse
com.            172800  IN  NS  l.gtld-servers.net.
com.            172800  IN  NS  j.gtld-servers.net.
com.            172800  IN  NS  h.gtld-servers.net.
…
;; Query time: 71 msec

Ask a .com server (192.41.162.30). It doesn't know the answer either, but it knows who is authoritative for ytamang.com, and that's Amazon Route 53:

$ dig @192.41.162.30 learn.ytamang.com A +norecurse
ytamang.com.        172800  IN  NS  ns-253.awsdns-31.com.
ytamang.com.        172800  IN  NS  ns-669.awsdns-19.net.
ytamang.com.        172800  IN  NS  ns-1550.awsdns-01.co.uk.
ytamang.com.        172800  IN  NS  ns-1183.awsdns-19.org.
ns-253.awsdns-31.com.   172800  IN  A   205.251.192.253

Ask the authoritative server. This one actually has the answer:

$ dig @205.251.192.253 learn.ytamang.com A +norecurse
learn.ytamang.com.  300 IN  A   5.75.145.2
;; Query time: 54 msec
   your laptop          recursive resolver                 the DNS hierarchy
       β”‚                       β”‚
       β”‚ learn.ytamang.com? ──▢│
       β”‚                       │── β‘  ──▢ root (.)          "ask .com: l.gtld-servers.net…"
       β”‚                       │── β‘‘ ──▢ .com TLD          "ask Route 53: ns-253.awsdns-31.com…"
       β”‚                       │── β‘’ ──▢ ns-253.awsdns-31  "5.75.145.2, TTL 300"
       │◀── 5.75.145.2 ────────│
       β”‚                       β”‚   caches every answer for its TTL

Notice the 4 nameservers on 4 different top-level domains (.com, .net, .co.uk, .org). Route 53 does that on purpose, so that a problem with one TLD can't take a domain offline.

TTLs: why DNS is usually fast

Every answer carries a TTL (time to live) in seconds. The .com delegation has a TTL of 172800 (2 days). Our A record has 300 (5 minutes). The resolver caches each answer for that long, so the next lookup skips the walk. Ask again a bit later, and the resolver returns the cached record with the TTL counting down:

learn.ytamang.com.  204 IN  A   5.75.145.2      ← 96 seconds into the 300-second TTL

This explains the classic "I changed DNS but nothing happened" problem: resolvers all over the world keep serving the old answer until their copy's TTL runs out. Lower the TTL before a migration, not during it.

Pro tip: query times of 38–71 ms here are mostly the WSL virtual network plus distance to the resolver. On a typical home connection with a warm cache, DNS takes 1–20 ms, and browsers also prefetch DNS for links on the page.

Step 4: TCP, Opening a Reliable Connection

With an IP address in hand, the browser opens a TCP connection to 5.75.145.2:443. TCP's three-way handshake costs exactly one round trip before any data can flow:

  laptop (Europe)                                          server (Hetzner, Germany)
  192.168.x.x:51234                                        5.75.145.2:443
       │──── SYN (seq=x) ─────────────────────────────────────────▢│
       β”‚                          ~26 ms                           β”‚
       │◀──────────────────────────── SYN-ACK (seq=y, ack=x+1) ────│
       │──── ACK (ack=y+1) ───────────────────────────────────────▢│
       β”‚                                                           β”‚
       β”‚  connect() returns here: ~1 RTT β‰ˆ 53 ms after the SYN     β”‚

The round-trip time to this server, measured with ping:

$ ping -c 3 5.75.145.2
rtt min/avg/max/mdev = 51.963/53.013/54.954/1.374 ms

And the curl number matches: TCP connect finished at 110 ms, 69 ms after DNS finished at 41 ms: one round trip plus a little scheduling noise.

The path in between

Your packets don't go straight there. They're forwarded router by router, and each router makes an independent decision based on its routing table. tracepath (or mtr, or traceroute) shows the hops by sending packets with small TTLs and listening for the "time exceeded" messages that come back:

$ tracepath -n 5.75.145.2
…
15:  213.239.239.142     57.888ms      ← Hetzner's backbone network
16:  no reply
17:  49.12.141.221       74.383ms      ← inside the data centre
…
     Resume: pmtu 1500

About 18 hops, and a path MTU of 1500 bytes: the biggest packet that fits through every link. Subtract 40 bytes of IP and TCP headers and you get the 1460-byte MSS that every TCP segment will respect. "No reply" lines are normal: many routers simply don't answer these probes.

Step 5: TLS, Proving Identity and Agreeing on Keys

Now the browser and server negotiate encryption. With TLS 1.3, this takes one more round trip:

  browser                                                        nginx
     │── ClientHello ────────────────────────────────────────────────▢│
     β”‚     SNI: learn.ytamang.com    (which site? nginx hosts four)    β”‚
     β”‚     ALPN: h2, http/1.1        (which HTTP version?)             β”‚
     β”‚     key_share: X25519 public key                               β”‚
     │◀──────────────────────────────────────────────── ServerHello ──│
     β”‚     TLS 1.3, TLS_AES_256_GCM_SHA384, key_share: X25519          β”‚
     │◀── {EncryptedExtensions: ALPN = h2} {Certificate chain}  ──────│
     │◀── {CertificateVerify} {Finished} ─────────────────────────────│
     │── {Finished} ──────────────────────────────────────────────────▢│
     │══ HTTP/2, encrypted with AES-256-GCM ══════════════════════════│

Two fields in the ClientHello are worth understanding:

SNI (Server Name Indication) tells the server which hostname you want. This one server (one IP address) hosts several sites, so nginx needs the name before it can choose which certificate to send. SNI is sent in plaintext, which is why your network can see which site you visit even over HTTPS. Encrypted Client Hello (ECH) is the newer fix for that.

ALPN (Application-Layer Protocol Negotiation) lets the client offer HTTP versions inside the handshake, so no extra round trip is needed to agree on one:

$ openssl s_client -connect learn.ytamang.com:443 -servername learn.ytamang.com -alpn h2,http/1.1
ALPN protocol: h2
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server Temp Key: X25519, 253 bits

The certificate chain

The server sends its certificate plus the intermediate certificates needed to link it to a root that your browser already trusts:

$ openssl s_client -connect learn.ytamang.com:443 -servername learn.ytamang.com
 0 s:CN = learn.ytamang.com
   i:C = US, O = Let's Encrypt, CN = YE2
 1 s:C = US, O = Let's Encrypt, CN = YE2
   i:C = US, O = ISRG, CN = Root YE
 2 s:C = US, O = ISRG, CN = Root YE
   i:C = US, O = Internet Security Research Group, CN = ISRG Root X2
 3 s:C = US, O = Internet Security Research Group, CN = ISRG Root X2
   i:C = US, O = Internet Security Research Group, CN = ISRG Root X1
Verification: OK

Read each pair as "s: subject was signed by i: issuer". The browser walks up the chain until it reaches a certificate already in its trust store. Let's Encrypt sends this long chain so that old devices which only trust ISRG Root X1 can still verify it.

   ISRG Root X1   ◀── trusted by almost every device (in the OS trust store)
        β”‚ signs
   ISRG Root X2   ◀── newer root, cross-signed by X1 for compatibility
        β”‚ signs
   Root YE        ◀── another Let's Encrypt root, again cross-signed
        β”‚ signs
   YE2            ◀── intermediate: does the day-to-day signing
        β”‚ signs
   learn.ytamang.com   notBefore Oct 4 2026, notAfter Jan 2 2027 (90 days)

The leaf certificate is valid for only 90 days. Short lifetimes limit the damage if a key leaks, and they force automation: on this server, certbot renews it automatically. The browser also checks the name (DNS:learn.ytamang.com in the Subject Alternative Name), the dates, and that the server signed the handshake with the matching private key.

The key exchange is X25519 Diffie-Hellman: both sides send a public key, both compute the same secret, and the secret itself never crosses the wire. Why that's secure (and what would break it) is the subject of the P vs NP tutorial.

Step 6: The HTTP Request

Finally the browser can ask for the page. Over HTTP/2 the request isn't text on the wire; it's a binary HEADERS frame on stream 1, with header names compressed by HPACK. Logically, though, it's the same request it would be in HTTP/1.1:

:method: GET
:scheme: https
:authority: learn.ytamang.com
:path: /
user-agent: Mozilla/5.0 (…)
accept: text/html,application/xhtml+xml,…
accept-encoding: gzip, deflate, br, zstd
accept-language: en-GB,en;q=0.9

HTTP/1.1 vs HTTP/2 vs HTTP/3

HTTP/1.1 HTTP/2 HTTP/3
Wire format Text Binary frames Binary frames
Requests per connection at once 1 (browsers open about 6 connections) Many, multiplexed as streams Many, multiplexed as streams
Transport TCP TCP QUIC over UDP
Head-of-line blocking Per connection At the TCP layer: one lost packet stalls every stream None between streams
Handshake before first request TCP + TLS = 2 RTT TCP + TLS = 2 RTT QUIC with TLS built in = 1 RTT (0 on resume)

This server speaks HTTP/2 (http=2 in the curl output). Forcing HTTP/1.1 gives about the same time for a single page, because multiplexing only helps when there are many requests:

$ curl --http1.1 -s -o /dev/null -w 'tcp=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer}\n' https://learn.ytamang.com/
tcp=0.099570 tls=0.178726 ttfb=0.278613

Connection reuse is the biggest win

The second request to the same host costs no DNS, no TCP and no TLS. It reuses the open connection:

$ curl -s -w '%{time_connect} %{time_appconnect} %{time_starttransfer} %{num_connects}\n' \
    -o /dev/null https://learn.ytamang.com/ -o /dev/null https://learn.ytamang.com/0016-p-vs-np/
0.000000 0.000000 0.053632 0          ← second URL: 0 new connections, TTFB = 1 RTT

First request: 233 ms to the first byte. Second request: 54 ms, exactly one round trip. That's why browsers keep connections open, why HTTP/2 puts everything on one connection, and why a page that pulls resources from ten different domains is slow.

Step 7: The Server Side

On the server, a lot happens in about 50 ms of TTFB (most of which is actually the network, not the server):

   NIC β†’ kernel TCP stack β†’ accept queue of the :443 listening socket
     β†’ nginx worker (event loop on epoll) accepts the connection
     β†’ TLS handshake (OpenSSL inside nginx)
     β†’ HTTP/2 frame decoded: :authority = learn.ytamang.com
     β†’ server block chosen by server_name, root = /var/www/html/learn.ytamang.com
     β†’ path "/" β†’ index.html β†’ open() + read() (from the page cache, no disk)
     β†’ response headers built, body gzipped, encrypted, written to the socket

nginx serves static files from a handful of worker processes, each running an event loop that can juggle thousands of connections. For a dynamic site, this is where a reverse proxy would forward the request to an application server, which might talk to databases and other services. That's the journey traced in Thinking Like a Systems Engineer.

Step 8: The Response

$ curl -sI https://learn.ytamang.com/
HTTP/2 200
server: nginx/1.24.0 (Ubuntu)
date: Mon, 30 Nov 2026 19:21:06 GMT
content-type: text/html
content-length: 15479
last-modified: Mon, 30 Nov 2026 19:08:43 GMT
etag: "6b0dc9bb-3c77"
accept-ranges: bytes
Header What the browser does with it
200 Success. A 301/302 would start the whole journey again at the new URL
content-type: text/html Choose the HTML parser (not "download this file")
content-length: 15479 Know where the body ends
etag: "6b0dc9bb-3c77" Fingerprint of this version, stored for revalidation
last-modified Another way to revalidate
server Nothing. It only tells attackers which nginx version runs here (hide it with server_tokens off;)

Compression

The browser sent accept-encoding: gzip, …. When curl asks for gzip too, nginx compresses the HTML:

$ curl -sI -H 'Accept-Encoding: gzip' https://learn.ytamang.com/ | grep -i encoding
content-encoding: gzip
$ curl -s --compressed -o /dev/null -w 'size=%{size_download}\n' https://learn.ytamang.com/
size=4700

15,479 bytes became 4,700: 70% smaller. Text compresses very well. Smaller responses fit in fewer TCP round trips, which matters because a new TCP connection starts with a small congestion window (10 segments, about 14 KB) and grows only as ACKs come back.

Revalidation with ETag

The next time the browser needs the page and its cached copy might be stale, it doesn't download it again. It asks "has it changed?":

$ curl -s -o /dev/null -w '%{http_code}\n' -H 'If-None-Match: "6b0dc9bb-3c77"' https://learn.ytamang.com/
304

304 Not Modified has no body. One round trip, a few hundred bytes, and the browser uses its cached copy. With a Cache-Control: max-age=… header, the browser wouldn't even ask. This site doesn't set one for HTML, so browsers decide for themselves how long to trust their copy (a heuristic based on last-modified).

Step 9: Parsing, Rendering, Painting

Now the browser has bytes. Turning them into pixels is a pipeline:

   bytes ──decode (UTF-8)──▢ characters ──tokenise──▢ tags ──tree build──▢ DOM
                                                                            β”‚
   CSS bytes ──parse──────────────────────────────────────────────▢ CSSOM  β”‚
                                                                      β”‚     β”‚
                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β–Όβ”€β”
                                                    β”‚  Style: which rules     β”‚
                                                    β”‚  apply to which nodes   β”‚
                                                    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
                                                    β”‚  Layout: sizes and      β”‚
                                                    β”‚  positions of each box  β”‚
                                                    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
                                                    β”‚  Paint: draw commands   β”‚
                                                    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
                                                    β”‚  Composite: layers β†’    β”‚
                                                    β”‚  GPU β†’ screen           β”‚
                                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Parsing is incremental. The browser starts building the DOM as soon as the first bytes arrive. When it meets <link rel="stylesheet"> it requests the CSS (on the same HTTP/2 connection). CSS blocks rendering: the browser won't paint until it has the styles, to avoid a flash of unstyled content.

Scripts can block parsing. A plain <script src> stops the HTML parser until the script is downloaded and run, because the script might call document.write. That's why scripts go at the end of <body> (as on this site) or get defer/async.

Layout is expensive. Changing an element's size makes the browser recompute positions of everything that depends on it. Animating transform and opacity is cheap because those only affect compositing.

The DevTools Performance tab shows this pipeline as a flame chart, and the Network tab shows the waterfall: DNS, Initial connection, SSL, Waiting (TTFB), Content Download for every request.

Where the Time Goes, and How to Make It Faster

Putting the real numbers together:

Stage Time on first visit Cost driver How sites reduce it
DNS 41 ms Resolver distance, cache misses Long-enough TTLs, dns-prefetch, fewer domains
TCP about 69 ms 1 RTT Servers closer to users (CDN), connection reuse
TLS about 71 ms 1 RTT (TLS 1.3) TLS 1.3, session resumption, HTTP/3 merges it with transport
Request β†’ first byte about 51 ms 1 RTT + server time Caching, fast backends
Download about 52 ms Size and TCP slow start Compression, smaller pages
Repeat visit 0 ms of network β€” Service Worker and HTTP caching

The physics is simple: light in fibre travels about 200 km per millisecond. A round trip from Europe to Germany is cheap; from Sydney it would be about 300 ms, and the four round trips above would take over a second. You can't make light faster, so you cut round trips and move content closer. That's what CDNs, HTTP/3, TLS 1.3, connection reuse and caching are all about.

Practice: Trace It Yourself

Pick any site you use and run these. Each command maps to one step of this article:

# Step 3: DNS, then walk the hierarchy by hand
dig example.com A +noall +answer +stats
dig @198.41.0.4 example.com A +norecurse          # root β†’ who runs .com?

# Step 4: round-trip time and path
ping -c 3 example.com
mtr -rwc 10 example.com

# Step 5: TLS version, cipher, ALPN and certificate chain
openssl s_client -connect example.com:443 -servername example.com -alpn h2,http/1.1 </dev/null

# Steps 6-8: timing breakdown, headers, caching, compression
curl -s -o /dev/null -w 'dns=%{time_namelookup} tcp=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total} http=%{http_version}\n' https://example.com/
curl -sI https://example.com/
curl -sI -H 'Accept-Encoding: gzip, br' https://example.com/ | grep -i encoding

Interview tip: a great answer to "what happens when you type a URL" isn't a list of steps; it's the steps plus the costs. Say how many round trips each stage takes, what's cached, and what you'd change to make it faster. That's the difference between memorising the answer and understanding it.

Copied to clipboard!