Every time you open a web page, two computers work together. One computer asks for the page. The other computer has the page and sends it. The one that asks is called the client. The one that sends is called the server.1
Your phone, tablet or laptop is a client. To look at web pages, you use an app called a browser, such as Chrome, Safari or Firefox. When you open a page, your browser is the one doing the asking.
Most of the time the client is a browser, but not always. Other programs on your devices, like the apps on your phone, ask servers for things too.1
A server is a computer that keeps a website’s files.2 A website is made of files, the same way your phone is full of photos and documents. Some files hold the words and the layout of the page. They are written in code called HTML, CSS and JavaScript. Other files are pictures and fonts. When a client asks, the server sends copies of those files.
One trip, start to finish
Opening a page happens in three steps:
- Your browser asks the server for the page.
- The server finds the files for that page.
- The server sends copies of the files back, and your browser puts them together into the page you see.
The asking has a name: a request. The answer has a name too: a response. Section 1.2 is all about those two.
The server keeps its own files. It only ever sends copies, so it still has the page for the next person who asks. A busy server answers lots of clients at the same time, the way one kitchen cooks for a whole restaurant.
One page, many files
A web page is usually not one file. It is several. When you open a page, your browser first asks for the HTML file. The HTML tells the browser which other files the page needs: a CSS file for how the page looks, a JavaScript file for the parts you can click and use, and the pictures. The browser then asks the server for each of those files, one request for each.3 So opening one page can mean many requests.
What is inside a server
A server is two things working together. The first is the computer itself, the machine you could touch. The second is a program running on that computer, called an HTTP server. The HTTP server waits for requests, finds the right file and sends a copy back.2
How a server finds a file
Every request asks for one file by its name. The HTTP server looks for a file with that name. If it has the file, it sends a copy. If it does not have it, it still answers, but the answer is an error that says the file was not found. That error is called 404 Not Found.2
Where servers live
You could turn your own computer into a server, but most websites are not kept that way. A home computer gets switched off, and its address on the internet can change. So people usually pay a hosting company to keep their website on a server that stays on, keeps the same address, and is looked after for them.2
Hosting companies keep their servers in buildings called data centres. Inside, servers sit in tall cabinets called racks. A data centre has backup power for when the electricity fails, cooling to stop the machines getting too hot, and fast connections to the internet.4
Worth knowing
- A server is a normal computer. Most servers have no screen. They stay switched on day and night, so they can answer whenever someone asks.2
- A server and a website are not the same thing. The website is the files. The server is the computer that keeps them, and one server can keep many websites.2
- Client and server are jobs, not special kinds of computer. Later in this course you will turn your own laptop into a small server, and the browser on that same laptop will be its client.
Exercises
Answer from memory. Scrolling up first only makes it feel easier.
1You open a news website on your phone. Which one is the client?
2What does a server do when a client asks for a page?
3You open one web page. How many requests does your browser usually send?
4A client asks for a file the server does not have. What comes back?
5Why do most servers stay switched on all day?
6Why do most websites live on servers at a hosting company?
7Can your laptop be a server?
0 of 7 right