Track 01 · Lesson 2 of 9How the web works

Track 01 · How the web works

The journey of a request

Lesson 2 of 9· 8 min

Loading a page is a relay race: find the server, connect, secure the line, ask for the page, then draw it. Step through it, then compare a first visit with a repeat visit.

Follow one page load

Use the steps, or press Play all

Step 1 of 6

1. Check the cache

1 ms

Before going anywhere, the browser checks whether it already has a fresh copy of the page or its files.

Analogy
Checking the fridge before going to the shop.
In DevTools
Requests served this way show “(disk cache)” or “(memory cache)”.

Timing waterfall, like the Network tab in DevTools

Six steps, every time#

  1. Cache. The browser checks whether it already has a fresh copy.
  2. DNS. It turns the name shop.example.com into an IP address.
  3. TCP. It opens a reliable connection to that address.
  4. TLS. For https, it checks the server's certificate and agrees on encryption keys.
  5. HTTP. It finally asks for the page, and the server answers.
  6. Render. It turns the HTML, CSS and JavaScript into pixels, and every file it finds on the way can start this race again.

Why the second visit is faster#

Switch the demo to Repeat visit and watch whole steps drop to zero. The address is still cached, the connection was kept open, and the secure session is resumed. The request itself still happens, but the server can often answer 304 Not Modified: "your copy is still good", with no body to download.

Where the time goes#

Notice how little of the waterfall is actual downloading. Most of a page load is waiting: for lookups, handshakes and the server to think. That's why the big speed wins are caching, keeping connections open, and putting servers closer to people with a CDN. You'll dig into caching in Inside the browser.

Check yourself

On a repeat visit, which steps can be skipped entirely?