How the web works
IGCSE Computer Science · The Internet and Its Uses
Internet and World Wide Web are not the same
| the internet | the global network infrastructure — the cables, routers and protocols that connect computers worldwide |
| the World Wide Web | the collection of web pages and websites that are accessed using the internet |
The internet is the road system; the web is the traffic travelling on it. Email, file transfer and online gaming also use the internet but are not part of the web.
The parts of a URL
A uniform resource locator has three parts:
$$\underbrace{\text{https://}}_{\text{protocol}}\ \underbrace{\text{www.example.com}}_{\text{domain name}}\ \underbrace{\text{/pages/index.html}}_{\text{file path and name}}$$- protocol — the set of rules used, usually $\text{http}$ or $\text{https}$;
- domain name — the name of the server holding the site;
- file path and name — which page on that server is wanted.
HTTP and HTTPS
HTTP is the protocol for transferring web pages. HTTPS is the same protocol with encryption added, using $\text{SSL}$ or $\text{TLS}$.
The single letter matters: with $\text{https}$, anyone intercepting the traffic sees only ciphertext. This is essential for passwords, card numbers and any personal data — and it is why browsers show a padlock.
The Domain Name Service
Computers find each other by IP address, a number. People remember names. The DNS bridges the two.
- the user types a domain name into the browser;
- the browser asks a DNS server for the matching IP address;
- if that server does not know it, it passes the request to another DNS server;
- the IP address is returned to the browser;
- the browser uses the IP address to request the page from the web server;
- the server sends the page back, and the browser renders it.
Note the browser's job: it does not store the pages. It requests them, then interprets the HTML and displays the result.
Cookies
A cookie is a small text file stored on the user's computer by a website.
| session cookie | held in memory and deleted when the browser closes — used for a shopping basket during one visit |
| persistent cookie | saved on the hard disk and survives closing the browser — used to remember logins, language and preferences |
Uses: saving preferences, keeping a user logged in, holding items in a basket, and tracking which pages a user visits for targeted advertising.
The last use is why cookies raise privacy concerns, and why sites must ask permission.
Digital currency and blockchain
Digital currency exists only electronically. Its problem is trust: without a bank, what stops someone spending the same coin twice?
Blockchain solves this with a decentralised digital ledger — a record of every transaction, copied across many computers.
Each block contains the transaction data, a timestamp, and a hash of the previous block. That last part is the key: changing an old block changes its hash, which breaks every block after it, so tampering is immediately visible.
Because the ledger is held on many computers rather than one, there is no single copy to attack or alter.
Worked example: tracing the path of a web page
A person types a web address into a browser. Describe the steps from typing to the page appearing, and state clearly the browser's role.
Solution
Step 1 — the user types the domain name. The user enters an address of the form $\text{https://www.example.com/index.html}$.
This address has three parts: the protocol ($\text{https}$), the domain name ($\text{www.example.com}$), and the file path ($\text{/index.html}$).
Step 2 — the browser asks a domain name server. Computers do not find each other by name but by IP address, a string of numbers. So the browser sends the domain name to a domain name server to ask for the corresponding IP address.
Step 3 — lookup, possibly via several servers. If that domain name server has no record for this name, it passes the request on to another domain name server until it is found.
Step 4 — the IP address is returned. The browser receives the number it needs.
Step 5 — request the page from the web server. The browser uses that IP address to send a request to the right web server holding the page. The server sends back the page's HTML code.
Step 6 — the browser renders the page. The browser interprets the HTML code and displays the result as the page the user sees.
The browser's role — a point often misunderstood.
The browser does not store web pages. It does three things: sends requests, receives HTML code, and interprets that code to display it.
Similarly, a domain name server holds no web pages at all — it is only a phone book that turns names into numbers. The real page is on the web server.
The role of the “s” in $\text{https}$. It shows that the data exchanged is encrypted using $\text{SSL}$ or $\text{TLS}$, so anyone who intercepts it sees only ciphertext. The browser displays a padlock icon to indicate this.
Worked example: why a blockchain resists data tampering
Explain the problem that digital currency has to solve, how a blockchain solves it, and why altering an old block is detected immediately.
Solution
The problem to solve: trust.
With cash, handing a note to someone else means you no longer have it. With digital currency, a “coin” is only data — and data can be copied.
So what stops a person spending the same coin twice? The traditional answer is to have a bank in the middle keeping the ledger. But then everyone has to trust that bank, and it becomes a single point that can make mistakes or be attacked.
How a blockchain solves it.
It uses a decentralised digital ledger: a record of every transaction, copied across a very large number of computers.
Because there is no single copy, there is no single point to attack. To alter the ledger, an attacker would have to alter the record on the majority of machines at the same time — which is almost infeasible.
Why altering an old block is detected immediately.
Each block contains three things: the transaction data, a timestamp, and the hash of the previous block.
A hash is a value calculated from the entire contents of the block. Change even one character in the block and its hash changes completely.
Now suppose an attacker alters a transaction in block number $50$:
- the hash of block $50$ changes;
- but block $51$ still records the old hash of block $50$ — so it no longer matches;
- to cover this up, the attacker would have to alter block $51$ too — but doing so changes block $51$'s hash, and block $52$ no longer matches;
- and so on all the way to the last block.
In other words, altering an old block forces you to recalculate the entire chain after it, and to do so on the majority of computers in the network faster than the network is creating new blocks.
That is why a blockchain is considered tamper-resistant: not because it is impossible to alter, but because the alteration is exposed immediately and the cost of hiding it is unaffordable.