Clients, Servers & HTTP
The big picture
The web is a conversation between clients (browsers, apps) and servers (computers that store websites and data).
- You type a URL or tap a link.
- The browser sends an HTTP request to a server.
- The server sends back an HTTP response: HTML, CSS, JavaScript, images or JSON.
- The browser shows the page.
Anatomy of a URL
https://shop.example.com:443/products/42?color=red#reviews
| Part | Example | Meaning |
|---|---|---|
| Protocol | https | how to talk (secure HTTP) |
| Domain | shop.example.com | which server |
| Port | 443 | usually hidden (80 for HTTP, 443 for HTTPS) |
| Path | /products/42 | which resource |
| Query | ?color=red | extra parameters |
| Fragment | #reviews | a spot on the page (never sent to the server) |
HTTP methods and status codes
GETread,POSTcreate,PUT/PATCHupdate,DELETEremove.2xxsuccess (200 OK, 201 Created),3xxredirect,4xxyour mistake (404 Not Found, 401 Unauthorized),5xxserver error (500).
HTTPS
HTTP inside TLS encryption: nobody in between can read or change the data, and the certificate proves the site is real. Always use HTTPS.
Front end vs back end
- Front end: what runs in the browser (HTML, CSS, JavaScript).
- Back end: what runs on the server (APIs, databases, authentication).
- Full stack: both.
Example
// See a real HTTP request and response (paste into the JS editor or a browser console)
fetch("https://jsonplaceholder.typicode.com/todos/1")
.then((res) => {
console.log("Status:", res.status); // 200
console.log("Type:", res.headers.get("content-type")); // application/json
return res.json();
})
.then((data) => console.log(data));
// { userId: 1, id: 1, title: "...", completed: false }