What happens when you type google.com in your browser and press Enter?

What happens when you type google.com in your browser and press Enter?

Table of contents

No heading

No headings in the article.

So I was in the coffee shop yesterday finishing up some tasks, then I had to google search some stuff, I picked up my phone and decided to ask google, I entered google.com into my browser and hit enter, then I began to think about what was happening under the hood. Come along, as I share them with you.

1. Firstly, we hit the DNS (Domain Name System) records

So basically, every URL points to an IP address, what is an IP address? An IP address is a unique set of numbers that are attached to every computer, as a house is identified by its address so is the computer by its IP address and our browser can't access a website without knowing the address to that website, the question now is, how can our browser discover this unique address? DNS record is the truth, they are instructions residing in a DNS server providing information about a domain including what IP address is associated with that domain and how to handle requests for that domain. So you can see the DNS record as your phonebook record where every name is pointing to a phone number.

So when you type google.com in the browser, the browser finds the DNS record by;

1. Checking browser cache: The browser has its storehouse of DNS records where it queries first for the records of google.com.

2. Checking the OS cache: If after checking the browser cache, the DNS records can't be found, a request is made to the OS cache through a system call for the DNS records of google.com. this is because the OS also has its DNS record storehouse from previously accessed records.

3. Checking the router cache: If still not found, the browser tells the router to search its cache for the record of google.com maybe it might be able to save the day.

4. Checking the ISP cache: If after checking the OS cache, the record isn't found, the browser requests your ISP provider to help search in the cache for the record of google.com, since the ISP provider also has its dedicated storehouse for DNS records.

5. Search for the server that has this record: Now, if we still can't get hold of this address, the ISP server starts a DNS query to pinpoint the server that holds the record google.com. Now, this search is called a recursive search. It searches from one DNS server to another to find the one with an idea of the record or where it will be found. These servers are called name servers., firstly, it searches the root domain server, then the top-level domain server before going to the authoritative name server. If the record of google.com is found, it returns the IP address of the server holding the resources to be accessed else it returns an error response showing it couldn't find this record.

2. Initiates Connection to the correct server and transfers data

Now, the browser takes this IP address and uses different internet protocols to create a connection with the server pointed to by the IP address. The most popular protocol is the TCP protocol, which helps to transfer data between the web server and the browser, so therefore, a TCP connection is set up for data transmission.

Next, the browser requests the web server by sending an HTTP request using the GET request if it wants to retrieve resources from google.com. else if it wants to send information to the web server it uses a POST request. This HTTP request has some header that has important information for the connection, e.g the connection header that keeps the connection alive, etc.

The web server handles the request made to it and sends out an HTTP response back to the browser, then the browser displays the piece of information or the resources requested for, commonly an HTML response.