Course outline · 0% complete

0/25 lessons0%

Course overview →

What happens when you type a URL

lesson 1-2 · ~12 min · 2/25

The whole journey in six steps

You type https://example.com/about in a browser and press Enter. Here is everything that happens, in order. This list is the map for the entire course.

  1. Parse the URL. The browser splits the address into pieces: which protocol, which server, which page.
  2. DNS lookup. The browser asks the DNS system to turn the name example.com into an IP address, something like 93.184.215.14. (Unit 2)
  3. TCP connection. The browser opens a reliable connection to that IP address. (Unit 3)
  4. TLS handshake. Because the URL starts with https, the browser and server agree on encryption keys so nobody can read the traffic. (Unit 7)
  5. HTTP request and response. The browser sends GET /about, the server sends back the page. (Units 4 to 6)
  6. Render. The browser turns the response into pixels, then repeats steps 2 to 5 for every image, stylesheet, and script the page needs.

All of this usually finishes in well under a second.

Browser(client)DNSname → IPServer93.184.215.141. where is example.com?2. GET /about → response
One page load: the browser first asks DNS for the server's address (gold dot travels down and back), then talks to the server itself.

Quiz

Which happens first when you press Enter on https://example.com/about?

Anatomy of a URL

A URL (Uniform Resource Locator) is a structured address. Every part tells the browser something specific:

https://shop.example.com:443/cart/items?color=blue
└─┬─┘   └──────┬───────┘└┬┘└────┬────┘ └───┬────┘
scheme        host      port   path      query
  • scheme: which protocol to speak. https means HTTP with encryption.
  • host: which server, by name. DNS will turn this into an IP address.
  • port: a number that selects which program on that server should receive the connection — one machine runs many network programs at once, and the port tells them apart (unit 2 covers this). Usually omitted because https implies 443 and http implies 80.
  • path: which resource on that server you want.
  • query: extra key=value details after the ?, joined by &.

Because a URL is just text with separators, you can pull it apart with any programming language. Let's do it in bash, which you already know from the terminal.

Code exercise · bash

Run this script. It splits a URL into scheme, host, and target (path plus query) using bash's built-in text trimming: ${url%%://*} keeps everything before the first ://, and ${url#*://} removes it.

Code exercise · bash

Your turn. Extend the script to also split the target into a path and a query. Print three lines: host, path (before the ?), and query (after the ?). Use ${target%%\?*} to keep what is before the ? and ${target#*\?} to keep what is after it.