How a website actually works
When you type a site address, your browser first translates the domain name into a numeric address, connects to the computer sitting behind it, receives a block of HTML text and builds the page from that text. A website is that short round trip, and every problem you see has happened in one link of that chain.
- Lesson 1 of 12
- Beginner
- Free, no signup
The two sides of a website, and what stands between them
The browser
on the user device, and what it does is build rather than receive a picture
- Sends the request and receives the answer
- Reads the HTML and CSS and builds the page
- Runs the JavaScript right there
The server
a computer that is never switched off and waits for requests
- Web server: takes the request, gives the answer
- The site application: produces the HTML
- The database: keeps text, users and orders
What brings these two together is the translation of a domain name into a numeric address
The domain and DNS
the phone book of the internet: from name to address
- A domain is only a rented name, not storage space
- A DNS answer is stored for a while, so a change is not seen at once
- The address it gives may belong to a middle layer
This drawing is simplified: in practice a content delivery network and a few cache layers usually sit between browser and server too.
Last checked: Facts and tool names in this lesson are re-checked against their sources on this date.
You type the address and hit enter; what happens next?
It is a round trip, not a live broadcast. Your browser sends a request, another computer answers, and the connection ends there. Every image, every CSS file and every font the page needs has its own separate request, so a simple looking page usually has dozens of round trips behind it.
The order is fixed. First the domain name has to be translated into a numeric address. Then an encrypted connection opens between the browser and that address, which is what the padlock beside the address bar is showing you. Then the browser says which page it wants. And the other side hands back a block of text.
What comes back is not a picture of the page, it is text. That same text becomes one shape on a phone and a different one on a monitor, and for someone using a screen reader it has no shape at all and is read aloud. The difference looks small and it explains the whole job of web design: you do not send the final look, you send the instructions for building it.
If you want to see it right now, right click on any site and choose view source. What opens is exactly the text your browser received.
One visit, from the enter key to the first thing you see
-
1
Translating the name
The browser asks where this domain is and gets a numeric address.
-
2
Opening a secure connection
The padlock beside the address; without it the browser warns you.
-
3
Requesting the page
The browser says which address it wants and introduces itself.
-
4
Producing the answer
Either a ready file is handed over, or the application runs and builds HTML.
-
5
Painting the page
The browser reads the text, fetches what it needs and builds the page.
These five stages cover the first file only. Images, fonts and scripts each run through the same cycle again.
The domain is a name and the IP is an address; who translates?
Computers do not work with names, they work with numbers. DNS is the phone book of the internet: you ask where rgb.ir is and you get back a numeric address. That question and answer takes a few hundredths of a second, and the answer is then stored for a while on your own machine and on the servers along the way, which is the main reason for that familiar sentence: it opens for me but not for you.
You can watch the translation yourself. In a Linux or Mac terminal:
dig +short A rgb.ir
dig +short NS rgb.irThe first command gives the numeric address and the second says who is responsible for answering questions about that domain. On Windows the same job is done by nslookup rgb.ir.
One thing that confuses beginners: the address that comes back is not necessarily the address of the real server. Many sites sit behind a content delivery network, so what DNS hands you is the nearest station of that network and the real server stays one layer further back. Our own site is exactly like that, and the numbers are in the section on what we did ourselves.
Do not confuse the domain with the hosting either: the domain is only a name and it is rented yearly, while hosting is where the files live. If that split is still fuzzy, the explanation of domains starts right there.
What is sitting at the other end of the line?
A computer that never gets switched off. What separates a server from your laptop is not the kind of parts inside it; it is that the machine is always on, sits on a fast connection and runs software that waits for requests.
Three things usually work side by side on it. First the web server, a program such as nginx or Apache that takes the request and hands back the answer. Second the site application, which may be PHP or any other language, whose job is producing HTML. Third the database, where the text of posts, the users and the orders are kept.
A simple page that is only a few lines of text can work without the last two. But the moment the site wants to receive a form, have users, or let content change from an admin panel, the application and the database come into play. WordPress is exactly that: a PHP application that reads content from a database and builds HTML out of it.
When you read about shared hosting, a virtual server or a dedicated server, the argument is about this same computer: how many sites sit on one machine and how its resources are divided. We have that on the hosting page with prices and specifications, though you do not need to decide anything now to follow this lesson.
Why are some pages ready and others built on every visit?
There are two models and both are correct. In the first, the HTML file is already sitting on the server and the web server simply hands it over: fast, cheap, no drama. In the second, the page is built at that moment: the application runs, asks the database, produces HTML and sends it. WordPress, online shops and anything that answers differently per user belong here.
The second model buys flexibility and it costs. Each visit means a handful of database queries and a few hundred milliseconds of processor work. The old and simple answer is the cache: the result is built once, stored as a ready file, and the next visitor gets that file. In other words, the dynamic site is temporarily turned into a static one.
That is what answers the perennial question: why is the change I made in the panel not showing on the site? Because the visitor is still being handed the previously stored copy. Until that copy is cleared or expires, your change is visible only to you, because you are logged in.
And there is one more layer above all of this: a content delivery network keeps a copy of the page near the user, so sometimes the request never reaches your server at all. For whoever builds the site that is good news, right up until the day they need to work out why the old version is still on screen.
A ready file, or a page built on the spot
Static: the file is ready in advance
- The web server just hands it over and nothing runs
- The fastest and cheapest case there is
- Every change means rebuilding and uploading the file
- Not enough on its own for forms, accounts and carts
Dynamic: built on the spot
- The application runs and queries the database
- Content changes from an admin panel, with no coding
- Can answer differently for each user
- Every visit costs processor work, so a cache is usually needed
Neither of these is better than the other. The choice depends on how often the content changes and how many people need to be able to change it.
Where does this chain break, and which piece do you see?
The good news is that the error message usually names the link that broke; you only have to know how to read it.
If the browser says the site cannot be found or the server name was not resolved, the request never reached your server and the problem is in name translation: a wrong DNS record or an expired domain. If you see a security warning, translation worked and the connection opened, but the SSL certificate is broken or expired. If you get a blank page or a 500 error, the request arrived and the site application failed midway; here you read the server error log, not the browser. And if everything opens but the content is old, nothing is broken at all: the cache is handing over the previous copy.
There is another category that is not a failure and looks like one: the site opens, but slowly. There the chain has not broken, one of its links is simply taking its time, and tracking that down is a separate job which the site speed path takes on.
One habit makes all of this easier: before guessing, look at the response headers. A short command tells you where the answer came from, which code it carried and whether a cache was involved:
curl -I https://example.com/That single line separates the site is down from the site is fine and the cache is serving yesterday copy.
AI in this kind of work
For someone just starting, the best use of a language model is not building the site for you; it is translating an error message you do not understand. Copy the exact text of the error, say where you saw it and what you did just before, and ask for a list of things to check. That is the job which used to take an hour of searching through forums.
Tools that actually help
- Claude Good at explaining an error and reading a chunk of a log. Iran is on neither of Anthropic supported-countries lists; we read that on Anthropic own page rather than measuring it.
- Gemini Handles Persian well and is enough for basic questions about domains and hosting. Google own page says the Gemini web app runs in over 230 countries and territories, and Iran is not on that list.
- ChatGPT The most common choice and acceptable for this job. We do not have an entry for it in our AI section yet, so we make no claim here about its access or pricing.
Where it backfires
The risk here is specific and it is not rare: the model invents something about your server in exactly the same confident tone. The path of a configuration file, the name of a screen in your control panel, or a command that is not even enabled on your hosting. Anthropic itself calls this hallucination in its own documentation and explains how to reduce it, which means the vendor treats it as a real weakness rather than a rumour. The rule is simple: anything the model says about your server has to be measured against real output, meaning the error log, the hosting panel, or that same curl -I. Explaining an error is the model job; confirming reality is yours. For how each of these tools can be paid for from Iran, see the buying guide.
Sources: Anthropic: reduce hallucinations Anthropic: supported countries Google: where Gemini Apps are available
Where this advice stops
This model is deliberately simplified. A real request today usually passes through several more layers that are not drawn here: a content delivery network, a load balancer, newer transport protocols, and code stored inside the browser itself. More importantly, understanding the chain repairs nothing; it only makes you look in the right place when you do repair something. Each link needs its own tools and knowledge.
From our own work
On the day this lesson was checked, we ran these commands against our own domain. dig +short NS rgb.ir returns two Cloudflare name servers, and dig +short A rgb.ir gives two addresses, neither of which is our server address; that is, what DNS hands your browser is the nearest station of the network, while the real server stays one layer back. Then curl -I https://rgb.ir/ returned a response carrying both cf-cache-status: HIT and an age header with a number of seconds, meaning the copy we received came from the edge and had been sitting there that long. The most interesting piece is that the same response also shows x-flying-press-source: PHP: the stored copy was built by PHP at some point, but today request never reached PHP at all. You can repeat all three commands against this same domain yourself.
Real follow-up questions
What exactly is the difference between a domain and hosting?
The domain is a name, the hosting is a place. You rent the name yearly and the place monthly or yearly; a domain with no hosting points nowhere, and hosting with no domain only opens through a numeric address. You can also buy the two from two different companies.
Why does the site open for me but not for someone else?
Most of the time the answer is DNS: the old address is still stored on the other person device or network, and until it expires that is what they get. The next candidates are the browser cache, a stored copy on the content delivery network, and the route being blocked on one particular network. The first move is testing the site on a different connection, mobile data for instance.
Do I need to know all of this to build a site?
No. With a hosting service and WordPress you can get a site running while knowing none of it. This lesson is for the day something stops working: then whoever knows the chain works out in minutes which company or which setting to go to.