Browsers and Servers
What happens when you type a URL and press Enter
Skills taught: web.browser-job, web.server-job, web.page-load-sequence
What the browser does
A browser is more than a window to the web. It is a sophisticated piece of software with multiple jobs: fetching resources, parsing code, executing scripts, and turning it all into the pixels you see on screen.
- Network layer — makes HTTP/HTTPS requests, manages caching, handles redirects
- HTML parser — reads HTML top-to-bottom, builds the Document Object Model (DOM)
- CSS engine — processes stylesheets, builds the CSS Object Model (CSSOM), computes styles
- JavaScript engine — executes JS code (V8 in Chrome, SpiderMonkey in Firefox, JavaScriptCore in Safari)
- Rendering engine — combines DOM + CSSOM into a render tree, calculates layout, paints pixels
- Compositing — assembles layers (like Photoshop layers) and sends them to the GPU
What the server does
A web server is software running on a computer that is always on, always listening for incoming connections. When a request arrives, it processes it and sends back a response.
- Static file server — sends files exactly as they are on disk (HTML, CSS, images). Fast, simple. GitHub Pages, Netlify, and KERNAL itself work this way.
- Application server — runs code to generate a response dynamically. Queries a database, applies business logic, returns JSON or HTML. Node.js, Python (Django/FastAPI), and Ruby on Rails apps do this.
- Reverse proxy — sits in front of application servers, routes traffic, handles SSL termination, and caches. Nginx and Cloudflare are common examples.
The full page-load sequence
You type: https://kernal.dhurta.org → press Enter
1. DNS lookup
Browser checks cache → OS cache → Router cache → ISP DNS server
Result: kernal.dhurta.org → 185.199.108.153 (GitHub Pages IP)
2. TCP handshake (3 messages)
Browser → SYN → Server
Browser ← SYN-ACK ← Server
Browser → ACK → Server
(Connection open. Time: ~50–200ms depending on distance)
3. TLS handshake (HTTPS)
Browser ↔ Server negotiate encryption keys
Server sends certificate proving its identity
(~1 additional round trip, or 0 with TLS 1.3 resumption)
4. HTTP request
GET / HTTP/1.1
Host: kernal.dhurta.org
Accept-Encoding: gzip, br
5. HTTP response
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
[HTML content starts streaming]
6. Browser starts parsing HTML (streaming, not waiting for full body)
Discovers: <link rel="stylesheet" href="/assets/index-abc.css">
Discovers: <script src="/assets/index-xyz.js">
→ Queues sub-resource requests immediately
7. Sub-resources downloaded (in parallel, HTTP/2)
CSS → CSSOM built
JS → parsed and executed
Images → decoded
Fonts → loaded
8. DOM + CSSOM → Render tree → Layout → Paint → Composite
Page appears on screen ✓
Tip: You can watch every step of this happen in real time using the Network panel in your browser's DevTools (F12). You will see each request, its timing, and its response.
Frequently Asked Questions
Why does my site feel slow after a DNS change?
DNS results are cached (TTL — Time To Live). When you change a DNS record, the old IP address is cached in ISP servers, routers, and browsers worldwide. Each cache expiry takes the TTL duration (often 1–24 hours). That is why DNS changes can take hours to 'propagate' worldwide.
What is TTFB (Time to First Byte)?
TTFB is the time from making the HTTP request to receiving the first byte of the response. It measures the combined time for DNS lookup + TCP + TLS + server processing. A high TTFB usually means the server is slow (database queries, heavy computation) or the server is geographically distant from the user.
Can a single computer be both client and server?
Yes, all the time in development. When you run npm run dev, your computer acts as the server (listening on localhost:5173) and your browser on the same machine is the client. The requests go over the network stack but never leave the machine — localhost is just a shortcut for 'this computer'.