Design & Development

Have You Ever Wondered How a Website Works?

In the most basic terms, a website is a collection of files on a server’s hard drive that the public can access. Since this is not a very satisfying explanation of what a website is or how it works, perhaps it is easier to follow the pathway from someone surfing the Internet to the website they are viewing.

Type in a domain name

When you fire up your favorite web browser and type in the domain name of a website you want to view, the first thing that happens is that a request is sent to the server that is hosting that website.

This server is found via the Domain Name System (DNS), which maps a domain name (understood by humans) to the address of the server hosting the website (understood by computers). Once the server receives the request, it checks the website files to determine what to do next.

The first file to be checked is the home page file, usually called “index.html” by default, although another file could be assigned as the home page. If this file is a dynamic script, such as a PHP file, the server runs the script and sends the appropriate HTML output back to the browser that made the request.

In the case of an HTML file, which does not require the server to do any processing, the file is sent or “served” directly back to the browser. This is referred to as a “response” from the server and completes the basic cycle that makes websites work: the browser makes a request, the server processes it, and the server returns an appropriate response to the browser.

Interpret the code

When the browser receives the response from the server, which is made up primarily of HTML code, it proceeds to “parse” or interpret the code. Most websites require much more than simply HTML code to display properly.

They also require images, Cascading Style Sheets, JavaScript, and other assets to display properly. As the browser interprets the HTML code, it encounters references to these assets, telling it to retrieve those files as well.

It is not uncommon for even a simple web page to require more than 15 separate files to display correctly, so the browser sends a request to the server for each file that it needs.

Display the website

Once all the files required to display a web page have been downloaded, the browser can render the page, and the loading process is complete.

We all remember waiting for images to download or watching a web page slowly piece itself together. Usually associated with a very slow Internet connection, the phenomenon is caused by the time it takes to download all the files needed to display a web page.

The process starts again when a link is clicked, which triggers the browser to request another file from the server.

Brian Getting
Brian Getting
Bio