In the most basic terms, a website is a collection of files on a server’s hard drive that can be accessed by the public. Since this is not a very satisfying explanation of what a website is or how one works, perhaps it is easier to follow the pathway between someone surfing the Internet and 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 server (DNS) system, which associates the domain name (which humans understand) and the address of the server that is hosting that website (which computers understand). Once the server receives that request, it looks at the website files to determine what happens 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, then the server runs the script, and the appropriate HTML output is sent 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 and the server processes that request and 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 will come upon references to these assets, telling the browser that it needs to get these 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
When all the files required to display a web page have been downloaded, the browser can correctly display the website, and the loading process is complete. We all remember waiting for images to download or watching as a web page slowly seemed to piece itself together. Usually associated with a very slow Internet connection, the phenomenon is caused by the amount of time it takes to download all of 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.