top of page
Writer's pictureTandid Alam

How The Web Works

Updated: Dec 19, 2022


Learn how the web works at the start of entering a URL into the browser to returning a web page


Contents


- What Happens When you Enter a URL into the Browser?

- Step 1: URL gets Resolved

- Step 2: A Request is Sent to the server

- Step 3: The Response of the Server is Parsed

- Step 4: The Page is Rendered and Displayed

 

What Happens When You Enter a URL into the Browser?


When we type a URL into the browser, our page often loads a website, file or an image, but what really goes on under the hood?


The image below shows the process of what happens, so let's see how this works.



Step 1: The URL Gets Resolved



Initially, the user (client-side) enters a URL into the browser which requests data from a server. This server (server-side) generally stores a website or helps generate a dynamic website for the client by giving the browser source code to interpret.


Definitions:


Domains are unique site URLs that refer to the main site address. Ex. amazon.com


Paths are relative to the domain and are often followed by the "/" character. Ex. amazon.com/cart


Together, the domain and path create a URL (Uniform Resource Locator).

"www" is a subdomain that stands for world wide web, and this redirects traffic to the main site.


Servers have their own addresses known as IP (Internet Protocol) Addresses. They typically look something like this: 431: 43: 123: 7


There's a special server called DNS Server which stands for Domain Name System. DNS Servers can be seen as a huge dictionary or library containing information that map domains to their IP Addresses. The browser is programmed to memorize DNS Servers by heart.


Now that we know these definitions, we can understand how the URL gets resolved. When entering a domain, the browser first fetches the IP address needed from the DNS Server in order to make a request to the proper server.


Step 2: A Request is Sent to the Server


Once we get the IP address, the browser makes a request to the server with that IP address.

To do this the browser sends data through HTTP (Hyper Text Transfer Protocol). HTTP is a standardized protocol which defines what a request (and response) has to look like, which data may be included (and in which form) and how the request will be submitted.



Did you notice how the browser typically auto completes your URL to have http in its name? That's because it's sending the request through HTTP. There's also HTTPS which is encrypted and securely sends data.


Once the request is made, the server handles the HTTP request and sends a response. Responses contain data like the code needed to render page onto the screen. Keep in mind that it doesn't have to contain a website.



Step 3: The Response From the Server is Parsed



While the browser gets the response, this doesn't necessarily do anything just yet because the data still needs to be parsed. Just like how the server parsed the

HTTP request, the browser does the same by checking data and metadata.


Say the response is a website for example, the response would contain a specific piece of metadata that tells the browser that the response data is of type text/html.


Knowing that its text/html, the browser can easily parse the data since it knows HTML in memory and it goes through the response data (response body) to render the website.



Step 4: The Page is Rendered and Displayed


The last step is the browser going through the response data and building a website. Keep in mind that a website contains more than the data that is fetched since it has to get data from other APIs, leading to multiple other requests.


It's important to note that not every response is a website and not every request wants a website. Both parties need to support the request and data so if there's a request in a URL asking for a PDF but the domain doesn't support PDFs, the server will send a bad request or error as a response.



Learning Resources:



Komentáře


bottom of page