Skip to content
← Writing

The Secret Life of a Website Visit

A fun, story-style walkthrough of what really happens when you type a URL: DNS, TCP, TLS/SSL, HTTP, caching, rendering, CORS, cookies, CDNs, and more.

  • 4 min read
Skip to contents
Contents
Cartoon flow titled ‘The Journey of a Web Request’: a browser window showing www.example.com passes through DNS to a server, then on through SSL, a padlock and CORS.

(or: Why your browser is basically a detective, courier, and diplomat all at once)

You type www.example.com into your browser and hit Enter. A page appears in seconds.

Behind the scenes? A whirlwind of detectives, phonebooks, border guards, chefs, and bodyguards. Here’s what happens, step by step.


Scene 1: Finding the Address (DNS)

Your browser only knows names like example.com, but the internet works on numbers (IP addresses).

  1. Browser cache → OS cache → DNS resolver.
  2. Resolver queries rootTLD (.com)authoritative server.
  3. Finally, we get example.com → 93.184.216.34.

Scene 2: The Road Trip (IP Routing)

Now that we have an IP, data packets travel like cars:

  • Hopping across routers, ISPs, and maybe undersea cables.
  • Each packet is wrapped like an onion: IP → TCP → HTTP → Data.
  • Packets may take different routes but arrive and reassemble in order.

If the site uses a CDN, you’ll probably hit a nearby edge server instead of the origin.


Scene 3: Knock Knock (TCP Handshake)

Before talking, the browser knocks:

SYN → SYN/ACK → ACK

Connection is now open.


Scene 4: Secret Handshake (TLS/SSL)

Before sending secrets, both sides agree on encryption.

  1. Server shows an SSL certificate (identity check).
  2. Browser verifies it (not expired, signed by trusted CA, matches hostname).
  3. Both agree on a cipher and exchange keys.
  4. Channel is now private — outsiders see only gibberish.

Scene 5: Ordering the Pizza (HTTP Request)

Your browser speaks first:

GET / HTTP/2
Host: example.com
User-Agent: Chrome/126.0
Accept: text/html
Accept-Encoding: gzip, br
Cookie: session=abc123

The server responds with a status code, headers, and body:

  • 200 OK → here’s your HTML.
  • 301/302 → redirect.
  • 404 Not Found → oops, no page.
  • 500 → server broke.

Scene 6: Don’t Reorder the Same Toppings (Caching)

Why redownload assets every time?

  • Browser cache stores logos, CSS, JS.
  • CDNs serve cached content closer to you.
  • Cache headers tell when to reuse vs revalidate:
Cache-Control: public, max-age=604800
ETag: "abc123"

If unchanged, the server replies 304 Not Modified, which is fast.


Scene 7: Kitchen Drama (Rendering)

The browser is now the chef:

  1. Parse HTML → DOM
  2. Parse CSS → CSSOM
  3. Build Render Tree
  4. Layout → Paint → Composite

JavaScript can change things mid-flight (React/Vue updates the DOM).


Scene 8: The Overprotective Bouncer (CORS)

Your page asks another domain for data. The browser checks:

Access-Control-Allow-Origin: https://example.com

If yes → allowed. If not → request blocked for safety.

That’s CORS: it prevents shady cross-site tricks.


Scene 9: Memory Keeper (Cookies & Storage)

Websites remember you using:

  • Cookies: session IDs, login state.
  • LocalStorage / IndexedDB: larger storage for apps.
  • Tokens: JWTs in headers for APIs.

Scene 10: Hidden Bodyguards (Security Headers)

Beyond TLS, sites add helmets:

  • HSTS: force HTTPS always.
  • CSP: stop rogue scripts (XSS).
  • X-Frame-Options: prevent clickjacking.
  • SameSite cookies: stop CSRF.

Scene 11: Hidden Superpowers

  • Service Workers: offline caching, push notifications.
  • HTTP/2 + HTTP/3 (QUIC): multiplexing, fewer round trips.
  • Load Balancers: distribute traffic across servers.
  • CDNs: edge caching, DDoS protection.

Scene 12: When Something Goes Wrong

  • DNS fails → ERR_NAME_NOT_RESOLVED.
  • Timeout → fallback server or retry.
  • Service worker may serve cached offline page.
  • If TLS cert is invalid → scary browser warning.

Scene 13: Voilà, the Feast

After DNS lookups, IP routing, TCP, TLS, HTTP, caching, rendering, CORS, cookies, security checks, and optimizations… the final page appears in milliseconds.

What looked like a simple click was actually hundreds of tiny conversations happening worldwide.


Recap in One Breath

  1. DNS finds the address.
  2. IP routing carries packets.
  3. TCP + TLS secure the lane.
  4. HTTP requests/serves content.
  5. Caching avoids duplicates.
  6. Rendering cooks pixels.
  7. CORS enforces boundaries.
  8. Cookies/tokens remember you.
  9. Security headers keep you safe.
  10. Optimizations + error handling make it smooth.

Next time you hit Enter on a URL, remember that none of it is magic. It’s a beautifully choreographed dance of networking concepts.

  • web-development
  • networking
  • dns
  • ssl
  • cors
  • http
  • browser
  • cdn
  • security

Comments