What happens when enter in holbertonschool.com in your browser

Juan Jose Carabali
7 min readSep 5, 2021

If you are in a profession that has to do with technology, I am sure someone has asked you this question at some point. Whether you are an engineer, developer, marketer or even in sales, it is always good to have a basic understanding of what goes on behind our browsers and how information is transferred to our computers via the Internet.

Let’s imagine you want to access holbertonschool.com to enter the software academy and learn how to make these fabulous blogs.

1.You type holbertonschool.com into the address bar of your browser.

2. The browser checks the cache for a DNS record to find the corresponding IP address of holbertonschool.com.

DNS(Domain Name System)
Is a database that maintains the name of the website (URL) and the particular IP address it links to. Every single URL on the internet has a unique IP address assigned to it. The IP address belongs to the computer which hosts the server of the website we are requesting to access.
For example, www.google.com has an IP address of 142.251.33.110. So if you’d like, you can reach www.google.com by typing http://142.251.33.110 on your browser. DNS is a list of URLs, and their IP addresses, like how a phone book is a list of names and their corresponding phone numbers.

The primary purpose of DNS is human-friendly navigation. You can easily access a website by typing the correct IP address for it on your browser, but imagine having to remember different sets of numbers for all the sites we regularly access? Therefore, it is easier to remember the name of the website using a URL and let DNS do the work for us by mapping it to the correct IP.

To find the DNS record, the browser checks four caches.

1.It checks the browser cache. The browser maintains a repository of DNS records for a fixed duration for websites you have previously visited. So, it is the first place to run a DNS query.

2. The browser checks the OS cache. If it is not in the browser cache, the browser will make a system call (i.e., gethostname on Windows) to your underlying computer OS to fetch the record since the OS also maintains a cache of DNS records.

3. It checks the router cache. If it’s not on your computer, the browser will communicate with the router that maintains its’ own cache of DNS records.

4. It checks the ISP cache. If all steps fail, the browser will move on to the ISP. Your ISP maintains its’ own DNS server, which includes a cache of DNS records, which the browser would check with the last hope of finding your requested URL.

Why many caches maintained at so many levels?
Although our information being cached somewhere doesn’t make us feel very comfortable when it comes to privacy, caches are essential for regulating network traffic and improving data transfer times.

3. If the requested URL is not in the cache, ISP’s DNS server initiates a DNS query to find the IP address of the server that hosts holbertonschool.com

In order for my computer to connect to the server hosting holbertonschool.com, I need the IP address of holbertonschool.com. The purpose of a DNS query is to search multiple DNS servers on the Internet to find the correct IP address for the website. This type of search is called a recursive search, as the search will continue repeatedly from a DNS server to a DNS server until it finds the IP address we need or returns an error response saying that it could not find it.

In this situation, we would call the ISP’s DNS server a DNS recursor whose responsibility is to find the correct IP address of the desired domain name by asking other DNS servers on the Internet for an answer. The other DNS servers are called name servers, as they perform a DNS lookup based on the domain architecture of the website’s domain name.
Look at the diagram below that explains the architecture of the domain.

https://flylib.com/books/en/2.203.1.109/1/

Many website URLs we encounter today contain a third-level domain, a second-level domain, and a top-level domain. Each of these levels contains their own name server, which is queried during the DNS lookup process.

For holbertonschool.com, first, the DNS recursor will contact the root name server. The root name server will redirect it to the .com domain name server. .com name server will redirect it to the holbertonschool.com name server. The holbertonschool.com name server will find the matching IP address for holbertonschool.com in its’ DNS records and return it to your DNS recursor, which will send it back to your browser.

These requests are sent using small data packets that contain information such as the content of the request and the IP address it is destined for (IP address of the DNS recursor). These packets travel through multiple networking equipment between the client and the server before it reaches the correct DNS server. This equipment use routing tables to figure out which way is the fastest possible way for the packet to reach its’ destination. If these packets get lost, you’ll get a request failed error. Otherwise, they will reach the correct DNS server, grab the correct IP address, and come back to your browser.

4. The browser initiates a TCP connection with the server.

Once the browser receives the correct IP address, it will build a connection with the server that matches the IP address to transfer information. Browsers use internet protocols to build such connections. There are several different internet protocols that can be used, but TCP is the most common protocol used for many types of HTTP requests.

To transfer data packets between your computer(client) and the server, it is important to have a TCP connection established. This connection is established using a process called the TCP/IP three-way handshake. This is a three-step process where the client and the server exchange SYN(synchronize) and ACK(acknowledge) messages to establish a connection.

1. The client machine sends a SYN packet to the server over the internet, asking if it is open for new connections.
2. If the server has open ports that can accept and initiate new connections, it’ll respond with an ACKnowledgment of the SYN packet using a SYN/ACK packet.
3. The client will receive the SYN/ACK packet from the server and will acknowledge it by sending an ACK packet.
Then a TCP connection is established for data transmission!

5. The browser sends an HTTP request to the webserver

Once the TCP connection is established, it is time to start transferring data! The browser will send a GET request asking for holbertonschool.com web page. If you’re entering credentials or submitting a form, this could be a POST request. This request will also contain additional information such as browser identification (User-Agent header), types of requests that it will accept (Accept header), and connection headers asking it to keep the TCP connection alive for additional requests. It will also pass information taken from cookies the browser has in store for this domain.
Sample GET request:

6. The server handles the request and sends back a response.

The server contains a webserver (Nginx, Apache, IIS) that receives the request from the browser and passes it to a request handler to read and generate a response. The request handler is a program (written in ASP.NET, PHP, Ruby, etc.) that reads the request, its’ headers, and cookies to check what is being requested and also update the information on the server if needed. Then it will assemble a response in a particular format (JSON, XML, HTML).

7.The server sends out an HTTP response.

The server response contains the web page you requested as well as the status code, compression type (Content-Encoding), how to cache the page (Cache-Control), any cookies to set, privacy information, etc.
Example HTTP server response:

If you look at the above response, the first line shows a status code. This is quite important as it tells us the status of the response. There are five types of statuses detailed using a numerical code.

  • 1XX indicates an informational message only
  • 2XX indicates success of some kind
  • 3XX redirects the client to another URL
  • 4XX indicates an error on the client’s part
  • 5XX indicates an error on the server’s part

So, if you encountered an error, you can take a look at the HTTP response to check what type of status code you have received.

8. The browser displays the HTML content (for HTML responses, which is the most common).

The browser displays the HTML content in phases. First, it will render the bare bone HTML skeleton. Then it will check the HTML tags and send out GET requests for additional elements on the web page, such as images, CSS stylesheets, JavaScript files, etc. These static files are cached by the browser, so it doesn’t have to fetch them again the next time you visit the page. In the end, you’ll see holbertonschool.com appearing on your browser.

Although this seems like a very tedious prolonged process, we know that it takes less than seconds for a web page to render after we hit enter on our keyboard. All of these steps happen within milliseconds before we could even notice.

That’s it!

--

--