Find a course

Module 4: The Web, Security and Who Runs ItLesson 8 of 1012 min

What Happens When You Load a Webpage

Break down a URL, follow HTTP requests and responses, read status codes like 200 and 404, and trace every step from typing an address to seeing a page.

Step 1 of 12Learn

Reading a URL

Every webpage has an address called a URL (Uniform Resource Locator). It packs several pieces of information into one line. Take this example:

https://shop.example.com:443/products/shoes?color=blue#reviews

  • https:// is the scheme (or protocol): use HTTPS, the encrypted version of the web's protocol.
  • shop.example.com is the host: the domain name to look up in DNS.
  • :443 is the port. It's usually left out, since browsers assume 443 for HTTPS and 80 for HTTP.
  • /products/shoes is the path: which page or resource on that server.
  • ?color=blue is the query string: extra information sent to the server, here a filter.
  • #reviews is the fragment: a spot within the page to jump to. It isn't even sent to the server; your browser handles it.

Reading URLs carefully is also a security skill. In example.com.login-secure.net, the real domain is login-secure.net, because domain names are read from right to left. Scammers rely on people noticing only the familiar word at the start.

Step 2 of 12Practice · Diagram

Taking a URL apart

Which part does DNS translate into an IP address?

Tap the shape that answers the question, then press Check.

Taking a URL apartParts diagram: One URL, six parts, https://, shop.example.com, :443, /products/shoes, ?color=blue, #reviews.One URL, sixpartshttps://shop.example-.com:443/products/s-hoes?color=blue#reviews
One URL, six parts

https://shop.example.com:443/products/shoes?color=blue#reviews

https://

Scheme: which protocol to use (secure HTTP).

shop.example.com

Host: the domain name DNS will look up. "shop" is a subdomain.

:443

Port: usually left out because 443 is the default for HTTPS.

/products/shoes

Path: which resource on the server.

?color=blue

Query: extra parameters, like a filter.

#reviews

Fragment: a spot within the page. Handled by the browser, not sent to the server.

Step 3 of 12Practice · Match the pairs

Match each part of the URL "https://news.example.org/sports/scores?team=hawks" to its name.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. https
  2. news.example.org
  3. /sports/scores
  4. ?team=hawks

Step 4 of 12Learn

HTTP: requests and responses

Browsers and web servers talk using HTTP (Hypertext Transfer Protocol). HTTP is a request–response conversation in plain, structured messages.

A request from your browser includes a method saying what it wants to do, the path, and headers with extra details such as your browser type, preferred language and any cookies for that site. The most common methods:

  • GET: "Please send me this resource." Used for loading pages, images and scripts.
  • POST: "Here is some data for you." Used when you submit a form, log in or post a comment.

The server answers with a status code, its own headers and usually a body: the HTML, image or other data.

Status codes come in families:

  • 2xx: success. 200 OK is the normal answer.
  • 3xx: redirection. 301 Moved Permanently tells the browser to go to a new URL.
  • 4xx: client errors. 404 Not Found means the page doesn't exist; 403 Forbidden means you're not allowed to see it.
  • 5xx: server errors. 500 Internal Server Error and 503 Service Unavailable mean the problem is on the server's side.

HTTP itself doesn't remember you between requests; it's stateless. Websites use cookies, small pieces of data your browser stores and sends back, to keep you logged in or remember your shopping cart.

Step 5 of 12Practice · Sort into groups

Sort each status code by what it means.

Tap an item, then tap its group (or drag it there).

Step 6 of 12Practice · Diagram

HTTP status code families

You mistype a page address on a working site. Which family will the error come from?

Tap the shape that answers the question, then press Check.

HTTP status code familiesHierarchy diagram: Status codes, 2xx Success, 3xx Redirect, 4xx Client error, 5xx Server error, 200 OK, 301 Moved permanently, 404 Not found, 403 Forbidden, 500 Internal error, 503 Unavailable.Statuscodes2xxSuccess3xxRedirect4xxClienterror5xxServererror200 OK301 Movedpermanently404 Notfound403Forbidden500Internalerror503Unavailable
Status codes
2xx Success
3xx Redirect
4xx Client error

The request was wrong: bad address, not allowed, not logged in.

5xx Server error

The request was fine but the server failed.

200 OK
301 Moved permanently
404 Not found
403 Forbidden
500 Internal error
503 Unavailable

Step 7 of 12Learn

From typing to seeing: the full trip

Now you can put the whole course together. When you type https://example.com and press Enter:

  1. DNS lookup: the browser checks its caches, then asks a resolver for example.com's IP address.
  2. TCP connection: the browser opens a connection to that address on port 443 with the three-way handshake (or uses QUIC over UDP with HTTP/3).
  3. TLS handshake: browser and server agree on encryption keys, and the browser checks the site's certificate. (Next lesson.)
  4. HTTP request: the browser sends GET / for the homepage.
  5. Response: the server replies 200 OK with an HTML document, sent as packets across many routers.
  6. More requests: the HTML refers to stylesheets (CSS), scripts (JavaScript), images and fonts. The browser requests each one, often dozens or hundreds of files, sometimes from other servers.
  7. Rendering: the browser builds the page structure, applies styles, runs scripts and paints pixels on your screen.

All of this often happens in under a second. Each step that needs a round trip adds latency, which is why engineers work so hard to cut round trips, reuse connections and place content closer to users.

Step 8 of 12Practice · Put in order

Put these steps of loading a website in order.

Drag the items, or use the arrow buttons, to put them in order.

  1. The browser renders the page on screen
  2. The browser sends an HTTP GET request
  3. The browser and server set up encryption with TLS
  4. The browser looks up the domain's IP address with DNS
  5. The browser opens a connection to the server

Step 9 of 12Practice · Diagram

From Enter to pixels

Which step happens only for HTTPS, not plain HTTP?

Tap the shape that answers the question, then press Check.

From Enter to pixelsProcess diagram: DNS lookup → TCP handshake → TLS handshake → HTTP request → Response → Render and fetch more.DNS lookupTCP handshakeTLS handshakeHTTP requestResponseRender and fetchmore
DNS lookup

Name to IP address, often answered from a cache.

TCP handshake

SYN, SYN-ACK, ACK: one round trip.

TLS handshake

Checks the certificate and agrees on encryption keys.

HTTP request

GET / with headers.

Response

Status code plus HTML.

Render and fetch more

The HTML asks for CSS, scripts and images, often dozens more requests.

Step 10 of 12Note

Step 11 of 12Practice · True or false

The fragment part of a URL, after the # sign, is sent to the web server along with the request.

Step 12 of 12Practice · Choose one

You click a link and get an error page saying "503 Service Unavailable." What does this most likely mean?