Course contents · Lesson 10 of 22

What Happens When You Type a URL and Press Enter?

The Web and Staying Safe · Lesson 10 of 22 · 8 min Foundations

You type a shop's address, press Enter, and a moment later the page appears. In that moment your browser uses ideas from all nine earlier lessons. This lesson answers what happens when you type a URL and press Enter, step by step, and shows you how to watch each step in your own browser.

The whole journey in eight steps

A URL (Uniform Resource Locator) is a full web address. Loading one takes eight steps, and the first seven each build on an earlier lesson. In the flowchart, notice the dashed shortcut: with a connection already open, the browser jumps from step 2 straight to step 6.

Flowchart of eight numbered steps in two rows. Step 1, read the URL: scheme, host and path, lesson 6. Step 2, check caches: saved files, DNS answers and open connections, lessons 3 and 4. Step 3, DNS lookup: name to IP address, lesson 3. Step 4, TCP handshake: SYN, SYN-ACK, ACK to port 443, lesson 5. Step 5, TLS handshake: check the certificate and agree keys, lesson 8. Step 6, HTTP request: GET /shop/shoes plus the site name and cookies, lesson 6. Step 7, response: through a load balancer, 200 OK and the HTML, lessons 4 and 6. Step 8, draw the page: fetch CSS, JavaScript and images, lay out, then paint, and the page is on screen. A dashed arrow from step 2 to step 6 says that with a connection already open, steps 3 to 5 are skipped. Colours group the steps into in your browser, find and connect, ask and answer, and draw the page
Seven steps reuse earlier lessons; an open connection skips three of them.

Steps 1 and 2: read the URL, then check what is saved

Take the URL https://www.example.com/shop/shoes?size=9. The browser first splits it into parts:

  • Scheme (https): which protocol to use. HTTPS means port 443 unless the URL names another, and HTTP means port 80 (lesson 2).
  • Host (www.example.com): which server to reach.
  • Path (/shop/shoes): which page on that server (lesson 6).
  • Query (?size=9): optional extra details, such as a search term.

Words that are not an address, such as red running shoes, go to your search engine instead.

Before using the network, the browser checks its caches, its stores of saved copies: files that sites said may be reused for a while, often images and styles (lesson 4); recent DNS answers (lesson 3); connections still open from earlier requests; and sites that said "HTTPS only", so it switches to HTTPS before sending anything.

Each saved item skips work. A fresh saved copy of a file needs no network at all, and an open connection skips steps 3 to 5.

Step 3: DNS turns the name into an address

Routers deliver packets by IP address, not by name, so the browser needs the number behind the host name. With no saved answer, your device asks its recursive resolver, the DNS server that does the whole search for you (lesson 3), and gets back an address such as 203.0.113.7, an example.

If the lookup fails, the journey ends with "This site can't be reached": with no address, the browser has nowhere to connect.

Steps 4 and 5: open a connection, then secure it

The browser opens a TCP connection to that address on port 443 with the three-way handshake: SYN, SYN-ACK, ACK (lesson 5). That costs one round trip: a message to the server and its reply back.

Next comes the TLS handshake (lesson 8): the server shows its certificate, the browser checks the name and dates, and both sides agree keys. TLS 1.3 needs one more round trip, the older TLS 1.2 two. A failed check shows a warning page instead of the site.

So a new HTTPS connection costs two round trips before the first request leaves. With HTTP/3, QUIC does both jobs together in one round trip, over UDP.

Steps 6 and 7: the request goes out, the response comes back

Now the browser sends an HTTP request (lesson 6), sealed inside TLS: GET /shop/shoes?size=9 for www.example.com, with headers that include any cookies it holds for that site (lesson 9).

The machine at that address is often not the one that builds the page. Big sites put a load balancer in front, which passes each request to one of many servers (lesson 14), or a CDN (content delivery network) server near you, which may answer from its own saved copy (lesson 17).

The server may ask a database for size 9 shoes (lesson 4), then answers 200 OK with the page's HTML (HyperText Markup Language) as the body. A redirect such as 301 sends the browser back to step 1 with a new address.

In the timeline, notice that waiting is the longest bar: one round trip plus the server's work. The second bar has no DNS, TCP or TLS, because the connection was reused.

Two timing bars with illustrative times, where one round trip takes 30 milliseconds. First visit, a new connection, about 220 milliseconds in total: DNS 20 ms, TCP 30 ms, TLS 30 ms, waiting for server response 120 ms, which is one round trip plus 90 ms of server work, then download 20 ms. TCP and TLS take one round trip each, and a bracket says Chrome's Initial connection figure covers both, 60 ms, with SSL included. Second bar, the next page on the same site with the connection reused: only waiting 120 ms and download 20 ms, about 140 ms in total, with no DNS, TCP or TLS. A note says Chrome's Timing tab calls these bars DNS lookup, Initial connection, SSL, Waiting for server response and Content download
A reused connection drops three bars: no DNS, no TCP handshake, no TLS.

Step 8: the browser builds the page

The browser reads the HTML as it arrives and finds links to more files: CSS (Cascading Style Sheets), the rules for colours and layout; JavaScript, programs that make the page interactive; and images.

Each file is another request, steps 6 and 7 again. Files from the same host can reuse the open connection, and with HTTP/2 many travel over it at once; files from another host usually need their own steps 3 to 5.

Some files hold up the rest. The browser waits for the page's CSS before drawing, so you don't see the page unstyled. An ordinary script, added without the word async or defer, pauses the reading of the HTML until it has downloaded and run. Images don't hold up the first drawing; they appear as they arrive.

Then the browser works out each element's size and position, called layout, and turns it into pixels, called painting. The table sets the whole trip beside the letter. Unlike a letter, it travels as many packets (lesson 1) and takes moments, not days.

Table matching eight postal steps to eight web steps. 1: write the address on the envelope, or read the URL: scheme, host and path. 2: check your drawer for a recent reply, or check caches and open connections. 3: look up the street address, or DNS turns the name into an IP address. 4: set up registered post, or the TCP handshake to port 443. 5: check their ID and agree a private seal, or TLS, where the certificate is checked and keys agreed. 6: post your request, or send the HTTP request. 7: the mailroom passes it to a clerk, who replies, or a load balancer, the server, then the response. 8: send for the leaflets and lay it all out, or fetch CSS, JavaScript and images and draw the page. A note says the real trip takes moments, not days, and travels as many packets
Each postal step has a web twin, in the same order.

Check yourself

Chrome says "This site can't be reached" because the server's IP address could not be found. Did the site's server ever hear from you?

No. Step 3, DNS, failed, so the browser had no address to connect to and steps 4 to 8 never started.

The second page you open on a site shows no DNS lookup, Initial connection or SSL in its Timing tab. Why?

The browser reused the connection opened for the first page, so it skipped steps 3 to 5 and their round trips.

Waiting for server response is 900 ms, while Initial connection is only 30 ms. Is the network or the server the likely problem?

The server. A quick connection means round trips are short, so most of the wait is the server building its reply.