By the end of this lesson you will be able to
- Explain what a web server is and where a website physically lives.
- Compare the main ways of hosting a site at a beginner level.
- Describe how a CDN makes pages load faster for people far away.
- Explain why cookies exist and how a session keeps you signed in.
- Describe a full browser request as a sequence of steps and name the client and server roles.
A website is not a cloud or a magic place. It is files on a computer somewhere, answering requests all day. Understanding where those computers are and how they remember you explains common experiences: why a site loads fast one day and slowly the next, why you stay signed in, and why a cookie notice appears on almost every page you visit.
What a web server really is
A web server is a computer, or the program on it, that stores the files of a website and sends them to browsers that ask. When you open a page, your browser is the Client and that computer is the Server, exactly as in the first lesson of this module. A server program waits on port 443 and answers every request that arrives, often thousands each second.
Some pages are just stored files, handed out as they are. Others are built on request: the server runs a small program, perhaps looks up your account in a database and assembles a page that is different for you. A news site shows the same articles to everyone; a bank shows your own balance.
Hosting: where the server lives
Hosting means renting space and attention on a computer that is always on and always connected. Nobody runs a website from a laptop on the kitchen table, because it would go off whenever the laptop slept. Hosting companies keep thousands of servers in a data centre: a building with backup power, cooling, security and very fast network links. You choose how much of the work you take on.
- Cheap and simple
- Owner looks after site files
- Busy neighbours can slow it
Good for small sites.
- Flexible
- Owner updates and secures the software
- Needs technical skill
More control, more work.
- Publish with an upload
- Provider keeps servers updated
- Very little maintenance
Easiest for simple sites.
Read this figure as text
A three-column comparison of shared hosting, a rented server and a managed platform.
Shared hosting: many small sites share one server; cheap and simple; the owner manages only the site's files; performance may dip if neighbours are busy. Rented virtual server: the owner rents a private slice of a server and looks after its software and security; flexible but needs technical skill. Managed platform or static site service: the provider runs the servers and the site is published with a few clicks or uploads; very little maintenance; the Computer Literacy Academy you are using is a static site of this kind. All three keep the site in a data centre.
CDNs: copies close to you
Distance matters. A request that must cross an ocean takes longer than one that travels across town. A content delivery network (CDN) solves this by keeping copies of a site's files, such as pictures, styles and videos, on many servers around the world. Your browser is sent to the nearest copy. The main computer that holds the original is the Origin server; it is asked only when a copy is missing or out of date.
Read this figure as text
A network diagram of a visitor, a nearby CDN copy and a distant origin server.
On the left a visitor's laptop. In the middle, a CDN server close to the visitor. On the right, far away, the origin server that holds the original website. Step 1: the laptop asks the nearby CDN server for the page's picture. Step 2: if the CDN already has a copy it replies at once, which is quick; this is the usual case. Step 3: only when the CDN has no copy does it ask the faraway origin server, store the answer and pass it on. Later visitors nearby then get the stored copy.
Your own browser keeps a copy too, called a Cache. If you revisit a site, it may reuse pictures it already stored. That is why a reload sometimes shows an old version of a page: the cache or a CDN held an earlier copy.
A page visit, start to finish
- Step 1: Read the URLYou press Enter
- Step 2: DNS lookupName to address
- Step 3: ConnectPort 443
- Step 4: TLSCheck certificate
- Step 5: Request and responseHTML, styles, pictures
- Step 6: Draw the pageBrowser shows it
Read this figure as text
A flow of six steps from typing an address to seeing the page.
Step 1: you type or click an address and the browser reads the URL. Step 2: DNS turns the domain name into an IP address. Step 3: the browser connects to the server's address on port 443. Step 4: TLS sets up a protected connection and checks the certificate. Step 5: the browser sends an HTTP request and the server (or a CDN copy) sends a response containing the page. Step 6: the browser reads the page, asks for the pictures and styles it names, and draws it on the screen.
Cookies and sessions: giving the web a memory
HTTP has no memory. Each request is a separate event, and the server does not automatically know that two requests came from the same person. To fix this, a site can ask your browser to store a small piece of text called a Cookie and send it back with every later request to that site.
Here is how a sign-in works. You send your username and password over HTTPS. The server checks them and starts a Session: a record on the server that says this person is signed in. It sends your browser a cookie holding a long random code that identifies that session. Your browser returns the code with every request, so the server recognises you without asking for the password again. When you sign out, or when the session expires, the server forgets the code.
Read this figure as text
A sequence diagram of a sign-in and later requests that carry a session cookie.
Two actors: the browser and the server of a made-up site. Message 1, browser to server: sign in with a username and password, sent over HTTPS. Message 2, server to browser: you are signed in, here is a cookie holding the session code 7f3a (a made-up value). Message 3, browser to server: give me my inbox, and the cookie with code 7f3a. Message 4, server to browser: the server finds the session for 7f3a, knows who you are and sends your inbox. If someone else got a copy of that code, the server would think they were you, which is why you should sign out on shared computers.
Cookies are used for three common jobs: keeping you signed in, remembering choices such as language or items in a shopping basket, and tracking, where advertising companies recognise you across many sites. Cookies set by the site you are visiting are called first-party. Cookies set by another company whose content is embedded in the page are third-party, and these are the ones used for most tracking. Browsers let you block or clear them, and many sites now ask your permission before using tracking cookies.
Your request travels down; the answer travels back up
Read this figure as text
A stack of layers from the browser on your device down to the database behind the web server.
Layers, from the top: first, your browser on your device (the client), which asks and displays. Second, the internet and any CDN, which carry the request. Third, the web server, which receives the request and decides what to send. Fourth, the application program behind it, which builds pages for you. Fifth, the database, which stores accounts, messages and orders. Each layer only talks to the one next to it.
Common mistakes
✖ Instead of: Believing that deleting cookies removes all your files or ruins the computer.
✔ Do this: Clearing cookies only signs you out of sites and forgets some preferences. Your own files are not touched.
✖ Instead of: Thinking a website exists 'in the cloud' with no particular place.
✔ Do this: It sits on real servers in real data centres, often with copies in several places.
✖ Instead of: Assuming a page you reloaded is always the latest version.
✔ Do this: A cache or a CDN may hold an earlier copy. A hard refresh (Ctrl+F5 on many browsers) asks for a fresh one.
If something goes wrong
- A site keeps signing me out.
- Check that your browser is not set to clear cookies every time it closes, and that the date and time on your computer are correct. Some sites also end sessions after a period of inactivity on purpose.
- A site says cookies are blocked, but I want to use it.
- Open the site settings for that site in your browser and allow first-party cookies for it. You do not need to allow third-party cookies for a site to work in most cases.
Key terms
- Data centre
- A building full of servers, with strong power, cooling and network links.
- Origin server
- The main server that holds the original copy of a website, which a CDN copies from.
- Web server
- A server that stores websites and sends pages to browsers that ask for them.
- Hosting
- A service that keeps a website's files on a server so people can visit it.
- CDN
- A group of servers around the world that keep copies of a website so it loads quickly for everyone.
- Cookie
- A small file a website saves in your browser to remember things about you.
Practise it for real
Reading is not the same as being able to do it. Complete these on your own computer, then tick only what you have actually done. These ticks are your own honest record: nothing checks them for you.
See which sites keep data in your browser
On your real computer, open your browser's settings and find the area about privacy, cookies or site data (names and positions vary by browser and release, so use the search box in settings). Look at the list of sites that have stored data. Do not delete anything yet. Write down three sites you recognise and one you do not.
Challenge: explain one visit
Without looking at the lesson, write the sequence of events from pressing Enter on https://example.org to seeing the page, using these words at least once each: DNS, TLS, request, response, server, CDN. Then add what happens differently when you sign in to an account on the next page.
Knowledge check
6 questions. You need 80% to pass. Mistakes here are part of learning, and you can retry as often as you like.
Summary
- A web server is a computer or program in a data centre that answers browsers' requests.
- Hosting is rented space on an always-on computer; the domain name is bought separately.
- A CDN keeps copies of files near visitors, and the origin server holds the original.
- HTTP has no memory; cookies and sessions are how a site remembers you.
Checklist: can you do these?
Marking a lesson as read does not prove you can do it. Skills count as demonstrated when you pass the quiz (not yet) and complete the practical tasks (not yet).
Related lessons
References and further reading
Official sources for details that can change between versions.
- What is a web server? (MDN Web Docs)
- Using HTTP cookies (MDN Web Docs)
- What is a CDN? (Cloudflare)