From Pressing Enter to a Rendered Page

DNS lookup, TCP and TLS handshakes, the HTTP request, the edge, the origin and the render

Follow one HTTPS page load end to end, from the browser's own caches through DNS, the network, TCP and TLS (or QUIC), the CDN edge and the origin, to the rendered page. Each layer has its own cache, its own failure and its own cost in round trips.

Overview

'What happens when you type a URL and press Enter?' is asked at every level, from new graduates to staff engineers, because there is no bottom to it. A good answer is not a list of acronyms. It is a chain of layers in the order they actually run, where each layer answers one question: is this already cached, where is the server, how do packets get there, how do we get a secure connection, who answers, and how does the answer become pixels.

The order matters, and it is where many answers slip. The browser looks in its own caches before touching the network. DNS runs before any TCP connection, and the DNS query is itself a packet, so the routing table and ARP for the default gateway are used before DNS, not after TLS. For a large site the address usually belongs to a CDN edge near you, not to the company's own servers, and many requests end there.

This topic uses abc.com as a stand-in for any site served over HTTPS behind a CDN. The records, addresses and timings are examples (addresses come from the ranges reserved for documentation), not any real site's.

Questions to ask first

Before you start, ask a few scoping questions. Here is each one with the answer this walkthrough assumes.

  • How deep should I go? Every layer briefly, then deeper wherever the interviewer pushes.
  • HTTP or HTTPS? HTTPS only, with HSTS.
  • Is there a CDN in front? Yes, and TLS ends at the edge.
  • What sits behind the CDN? A load balancer, stateless app servers, a cache and a database.
  • First visit or repeat visit? Both. The latency budget shows each.
  • Do you want numbers? Yes: a budget in round trips and milliseconds, from stated RTTs (round-trip times).

The path at a glance

The picture below is the whole chapter in one line, from the key press to the database. The sections that follow walk it from left to right.

In the interview

  • Walk the layers in order: browser, DNS, network path, connection, edge, origin, response, render.
  • At each layer, name its cache and what makes it miss.
  • Give a latency budget in round trips and milliseconds, with stated assumptions.
  • Say what fails at each layer and how you would see it.

What you will be able to do

  • Walk a page load in the right order, from the address bar to painted pixels.
  • Count the round trips of each phase and turn them into a time-to-first-byte budget.
  • Explain what TLS 1.3, QUIC, HSTS and connection reuse each save.
  • Say where each kind of response is served from and which cache headers decide it.
  • Name one failure per layer, the signal that shows it and how each layer scales.

Key concepts

  • HSTS
  • Browser HTTP cache
  • Stub and recursive resolvers
  • DNS TTL
  • Anycast and GeoDNS
  • TCP and TLS 1.3 handshakes
  • QUIC and HTTP/3
  • CDN edge cache
  • Cache-Control
  • Critical rendering path

Functional requirements

  • Turn what the user typed into a URL (scheme, host, port and path), or a search if it is not a URL
  • Serve the page from a service worker or the browser cache when a fresh copy exists
  • Resolve abc.com to an address near the user
  • Set up an encrypted connection to that address and send an HTTP request
  • Answer from the CDN edge when it has a fresh copy; otherwise forward to the origin
  • At the origin, route the request, run the handler, read from the cache and the database, and build the response
  • Return the response with a status code and caching headers, and render it in the browser

Non-functional requirements

  • Time to first byte at or under 0.8 s at the 75th percentile (a target we chose; web.dev gives it as a rough guide)
  • Largest Contentful Paint at or under 2.5 s and Interaction to Next Paint at or under 200 ms at the 75th percentile (the web.dev "good" thresholds, chosen as targets)
  • HTTPS only; after the first visit the browser never uses plain HTTP for the site (HSTS)
  • No single server, zone or edge location whose loss takes the site down
  • Bursts of traffic and attacks are absorbed at the edge before they reach the origin
  • Every layer is observable: DNS answers, connection times, cache hit ratio, origin latency and errors

Interview questions

  • What happens from the moment you press Enter in the address bar to the moment the page renders?
  • How does DNS resolution work when you enter a URL?
  • What is the difference between a DNS lookup, a TCP handshake and an HTTP request?
  • Why does the DNS lookup need ARP and the routing table?
  • How does the browser know which certificate to trust, and what does it check?
  • What does HTTP/3 change, and when is it not used?
  • Where is the page actually served from?
  • Users in one country report that the site is slow. How do you find the layer?
  • What do 502 and 504 mean, and who sends them?
  • How would you make the page load faster?

Sign up free to read the full topic

More System Design topics

Start free on Cariara · Coding problems · System design studio