How the Web Works
What actually happens in the second after you press Enter ā clients, servers, URLs, and HTTP, explained without jargon.
Before writing any code, you need a mental model of what a website is. Everything you build in this course plugs into this model, so it is worth ten unhurried minutes.
The internet and the web are not the same thing
The internet is a global network of computers that can send data to each other. The web (short for World Wide Web) is one service that runs on top of it: a system of documents ā pages ā linked together and fetched by your browser. Email and video calls also run on the internet, but they are not the web.
A website is a collection of pages that live together, usually under one address.
Clients and servers
Every website involves two roles:
- A client asks for things. Your browser ā Chrome, Firefox, Safari ā is the client.
- A server answers. A server is just a computer (somewhere in the world) that is always on, stores website files, and sends them out when asked.
When you type an address, your browser sends a request to the right server. The server sends back a response: the page's files. Your browser then does the actual work of turning those files into something you can see and click. This request ā response cycle repeats constantly ā once for the page, then again for each image, stylesheet, and script the page needs.
Anatomy of a URL
https://developer.mozilla.org/en-US/docs/Learn
āāā¬āā āāāāāāāāāāāā¬āāāāāāāāāā āāāāāāāā¬āāāāāāā
scheme domain (which path (which page
(how to server) on that server)
talk)
- The scheme (
https://) says how to talk to the server. HTTPS means the conversation is encrypted ā nobody between you and the server can read it. - The domain (
developer.mozilla.org) names the server. Domain names exist for humans: behind the scenes they are translated into numeric IP addresses by a global lookup system called DNS ā think of DNS as the internet's phone book. - The path (
/en-US/docs/Learn) says which page on that server you want.
HTTP: the conversation
The client and server speak a protocol called HTTP (HyperText Transfer Protocol). You never see the conversation, but it is simple: the request says "give me this path", and the response carries the content plus a status code saying how it went:
200ā here it is, all good404ā there is no page at that path500ā the server itself had a problem
You have seen these before: a 404 page is the server honestly saying "no such page".
Where the files live: hosting
For a website to be reachable, its files must sit on a server that is connected to the internet ā that is hosting. Later in this course (Module 5) you will publish a real page to GitHub Pages, a free hosting service, and everything in this lesson will click into place: your files will have a URL, and any browser in the world will be able to request them.
What you learned
- The web is a system of linked pages that runs on the internet
- Browser = client (asks); server = computer that answers
- A URL has a scheme, a domain, and a path; DNS turns domains into addresses
- HTTP is the request/response conversation; status codes summarize the outcome
- Hosting means storing your site's files on a reachable server
Next: what those files actually contain ā the three languages of a web page.