How the Web Works

Asking and answering over the web

Say what travels out in a request and what comes back in the answer, read the data an address carries, and follow what a browser does with the number it is answered with.

Every file a page is made of arrives the same way: the browser sends one request and the machine holding the page sends back one answer. The request says what is wanted — a word such as GET, and the path of the thing being asked for — and it can carry a little data of its own, written on the end of the address after a question mark as name-and-value pairs with ampersands between them, which is how a filled-in form usually travels. The answer comes back with a number at the front of it saying how the request went: 200 for here it is, 404 for there is nothing here by that name, 301 for it has moved and here is where to, 403 for you are not allowed, and 500 for something went wrong at my end. Then, if there is anything to send, the content itself.

Everything after the question mark is data, and it is in plain view

The pairs on the end of an address are ordinary information traveling to the machine that holds the page, and they are the reason an address can be long and full of equals signs. What is worth remembering about them is where an address goes afterwards: it sits in the address bar, it goes into the browser's history, it is what gets copied when somebody shares a link. So anything sent that way is visible to anyone who can see the address, which is fine for a search term and is why a password is never sent like this.

Worked example

What travels in each direction for this one request?

GET /shop/list?item=pen&size=large
  1. Going out: the word GET, saying that something is being fetched rather than sent; the path /shop/list, saying which thing; and two pairs of data — item is pen, size is large.

    The path and the data are separated by the question mark, and the two pairs from each other by the ampersand. Neither mark is part of any name or any value.

Try it together

Now follow a browser that keeps being pointed somewhere else.

A page has been moved twice, and the old addresses have both been left pointing at where it went.

    1.The browser asks for the original address and is answered 301. How many pieces of the page has it received so far?

    Have a go

    Have a go on your own. How many name-and-value pairs is this address carrying?

    /notes/list?topic=lists&sort=new&page=2

    Ready to practice?

    Eight questions on what you have just read. Nothing is timed, and you can play as many times as you like.

    Print a worksheet