The Web
How the Internet & Web Work
What happens when you open a website: clients and servers, IP addresses, DNS, TCP and packets, HTTP requests and responses, status codes, HTTPS, and front end vs back end.
The Internet is a global network of networks — billions of devices connected by cables, fibre, Wi-Fi and cell towers, all speaking common protocols (agreed rules). The World Wide Web, invented by Tim Berners-Lee in 1989, is one service that runs on top of the Internet: web pages linked together and fetched with HTTP. Email, video calls and online games are other services on the same Internet.
Clients and servers
- A client requests something — your browser or a mobile app.
- A server is a computer that waits for requests and responds — with a web page, an image, or data.
Addresses: IP and DNS
Every device on the Internet has an IP address:
- IPv4: four numbers 0–255, e.g.
142.250.193.78(about 4.3 billion addresses — not enough). - IPv6: eight groups of hex, e.g.
2404:6800:4007:81a::200e.
Humans prefer names. The Domain Name System (DNS) is the Internet's phone book: it translates a name such as www.example.com into an IP address, asking a hierarchy of DNS servers (root → .com → example.com) and caching the answer.
Packets, TCP and routing
Data travels in small packets. Each packet carries the source and destination IP addresses and is forwarded hop by hop by routers. Packets of one message may take different routes.
- IP delivers packets on a best-effort basis.
- TCP sits on top: it numbers packets, re-sends lost ones and reassembles them in order — a reliable stream. (UDP skips that for speed — video calls, games.)
What happens when you visit a website
HTTP: requests and responses
HTTP (HyperText Transfer Protocol) is a simple text conversation:
GET /courses/c HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
Accept: text/htmlHTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 1532
<!doctype html>
<html> ... </html>| Method | Meaning |
|---|---|
GET |
read a resource |
POST |
create something / submit a form |
PUT / PATCH |
update |
DELETE |
delete |
| Status code | Meaning |
|---|---|
| 200 OK | success |
| 301 / 302 | moved — redirect |
| 400 Bad Request | the request was malformed |
| 401 / 403 | not logged in / not allowed |
| 404 Not Found | no such resource |
| 500 Internal Server Error | the server crashed |
HTTPS is HTTP inside an encrypted TLS connection, so nobody between you and the server can read or alter the traffic — that is what the padlock in the address bar means.
URLs
https://shop.example.com:443/search?q=keyboard&page=2#reviews
| Part | Value |
|---|---|
| Scheme | https |
| Host (domain) | shop.example.com |
| Port | 443 (the default for HTTPS) |
| Path | /search |
| Query string | q=keyboard&page=2 |
| Fragment | #reviews (handled by the browser only) |
const url = new URL("https://shop.example.com:443/search?q=keyboard&page=2#reviews");
console.log(url.protocol, url.hostname, url.pathname);
console.log("q =", url.searchParams.get("q"), "| page =", url.searchParams.get("page"));
console.log("fragment:", url.hash);https: shop.example.com /search q = keyboard | page = 2 fragment: #reviews
Front end and back end
| Front end (client side) | Back end (server side) | |
|---|---|---|
| Runs in | the browser | a server |
| Languages | HTML, CSS, JavaScript | JavaScript (Node.js), Python, Java, Go, C# … |
| Job | layout, styling, interaction | data, logic, authentication, databases |
| Talks via | HTTP requests to APIs (often JSON) | HTTP responses |
A full-stack developer works on both.
Test yourself
4 questions · pick an answer to check it instantly
- 1
What does DNS do?
DNS is the Internet's phone book. - 2
Which HTTP status code means the page was not found?
4xx codes are client errors; 404 means the resource does not exist. - 3
Which protocol guarantees packets arrive complete and in order?
TCP re-sends lost packets and reorders them. - 4
What does the "S" in HTTPS add?
HTTPS is HTTP over an encrypted TLS connection.