How does a website work?
What happens between typing a web address and seeing the page: the browser, the name lookup, the server and the files it sends back.
A website is a set of files kept on a computer called a server, which stays connected to the internet. When you visit, your browser asks that server for the files and puts them together into the page you see.
The two sides: your browser and the server
Your phone or laptop, with the browser on it, is called the client. The server is the computer that stores the site. Mozilla’s guide for people learning the web compares the two to a house and a shop joined by a road: you go to the shop, ask for what you want and bring it home. Every page view is a trip like that, with a request from the browser and a response from the server.
What happens when you type an address
- The browser looks up the name. Servers are found by a number called an IP address, so the browser first asks the Domain Name System (DNS) which number belongs to the name you typed.
- The browser sends a request to that number, asking for the page. The request and the reply follow a set of rules called HTTP, or HTTPS when the connection is encrypted.
- The server answers. If all is well it replies with the code 200, which means OK, and starts sending the files. If it cannot find the page, it replies with 404.
- The files travel in small pieces called packets. A piece that is lost or damaged on the way is sent again, so the whole file does not have to be.
- The browser puts the pieces back together and shows the page.
The first step has a lesson of its own: What DNS is, and why your business depends on it.
What the files are
A page is made from code and assets. The code is written in three languages, HTML, CSS and JavaScript, which the browser reads and turns into the page. The assets are everything else that appears on it, such as images, video and PDF documents.
Some servers send the same stored files to every visitor. This is called a static site, and it is the simplest kind to set up. Other servers build each page at the moment it is asked for, usually by filling a template with content from a database. This is a dynamic site. It is more flexible and easier to keep up to date when there is a lot of content, and it is harder to build and look after.
Why a business owner should know this
Each step is a place where a visit can fail, and the steps often belong to different suppliers. If the name cannot be looked up, the problem is with the domain or its DNS records. If the name is found and the server does not answer, the problem is with the hosting. If the page arrives and looks wrong, the problem is in the site’s own files.
So when the website is down, the useful first question is which step failed. The answer tells you whether to call the company that holds the domain, the company that hosts the site, or the person who built it.
Sources
- How the web works (MDN Web Docs, Mozilla) developer.mozilla.org
- What is a web server? (MDN Web Docs, Mozilla) developer.mozilla.org
- RFC 9110: HTTP semantics (IETF) rfc-editor.org
- Introduction to computer networking, CS101 (Stanford University) web.stanford.edu