"From Click to Connection: What Happens When You Visit Type Instagram.com
Getting bored , lonely or just anxious . Called friends , no reply. Don't worry. The internet got your back. Online friends are just one click away.
Table of contents
- What is internet?😥
- What happens when you type a URL in your search bar?
- Step 0 : The browser parses the URL to check if it is valid or not.
- Step 1 : The browser sends a request to DNS to get the IP address and does a DNS lookup.
- Step 2 : The browser establishes a TCP connection to the server using the IP address.
- Step 2.1 : If the URL uses HTTPS(The browser sets up a secure SSL/TLS connection with the server)
- Step 3 : The browser sends a request to the server over a secure connection in the form of HTTP headers.
- **Request -Response Model (*just fun tech name for nerds*)
- Step 4: The server handles the request and sends back a response.
- Step 5 : The server sends the HTTP response containing the page content.
- Step 6 : The browser renders and displays the HTML content.
So go ahead, and open your browser, and type in “instagram.com” in your search bar. Ready to log into your IG account? But wait, have you ever wondered how your browser searched for this website in the chaos of thousands of websites? If yes, let’s dive in to understand this:😀
What is internet?😥
Internet is just a network of interconnected computers.🫨Simple, it helps us to share information and communicate with computers all over the globe.🌏
Let’s try to understand the components that make up the internet in brief:
Client device : Every computer connected has a unique IP address, that is its name.
Router : This router ensures that data packets don’t get mixed up, so your dad doesn’t read the message sent by you to your girlfriend(If you have one .lol😝)
Modem : It acts as a mediator between you and your ISP.
ISP : Internet Service Provider (In india, Jio , Airtel etc ) let you connect to the internet through them.
DNS : When you search for a website the DNS helps you to find the IP address of that website.
Server : From its name , we know , it servers us the data , website , files etc when requested by the client.
Internet’s Backbone : These underwire cables help in high speed data transfer and are placed in the ocean bed.
Now let’s debunk the entire process of you typing “instagram.com” on your browser’s search bar to getting the webpage instagram.com filled with photos and videos .
What happens when you type a URL in your search bar?
Step 0 : The browser parses the URL to check if it is valid or not.
Step 1 : The browser sends a request to DNS to get the IP address and does a DNS lookup.
Step 2 : The browser establishes a TCP connection to the server using the IP address.
Step 2.1 : If the URL uses HTTPS(The browser sets up a secure SSL/TLS connection with the server).
Step 3 : The browser sends a request to server over a secure connection in the form of HTTP headers .
Step 4 : The server handles the request and sends back a response.
Step 5 : The server sends the HTTP response containing the page content.
Step 6 : The browser renders and displays the HTML content.
Now let’s elaborate on each point :
Step 0 : The browser parses the URL to check if it is valid or not.
Here , the browser checks if it is a valid URL and follows the correct format (like”instagram.com” ).
Step 1 : The browser sends a request to DNS to get the IP address and does a DNS lookup.
A DNS lookup finds the IP address(157.240.22.174) of the domain name : here “instagram.com”.
If you want to perform a manual DNS lookup, just use the dig command in your terminal .
The browser looks for the IP address in various places like:
Browser’s Cache :
The browser first looks up in its cache to find the IP address, if not found
Local Network Cache :
The browser tries to find if the local network has the IP address , if the domain name is very common . Our search ends here . If not , then
DNS Server to rescue! :
The DNS server searches for the IP address associated with the domain name . If found returns the IP address. If not gives an ‘invalid URL’ or just an error message in the browser.
Step 2 : The browser establishes a TCP connection to the server using the IP address.
After the IP address is found, the browser establishes a TCP(Transmission Control Protocol) connection using a three-way handshake.
Importance of TCP:
It ensures reliable data delivery by breaking the data in smaller chunks and labelling each chunk by a sequence number . During handshake , the client and server exchange the sequence number to enable a secure connection.
In case of server downtime, network issues etc , this three-way handshake fails :
Step 2.1 : If the URL uses HTTPS(The browser sets up a secure SSL/TLS connection with the server)
If the URL uses a https:// instead of http://, where the ‘s’ in the https stands for secure. HTTPS uses TLS (Transport Layer Security) and SSL (Secure Sockets Layer) certificates to ensure encryption and security of data.
Step 3 : The browser sends a request to the server over a secure connection in the form of HTTP headers.
Now, that we have a secure TCP connection , the browser builds the request and sends it to the server using a Request -Response Model.
**Request -Response Model (*just fun tech name for nerds*)
It basically sends a request in the form of HTTP headers to the server and receives a response from the server.
A request is made up of three parts:
The Request Line : contains the HTTP method , resource location , and protocol version.
The Request Header : made up of key-value pairs containing(e.g.,
User-Agent
,Accept
,Host
,Authorization
)The Request Body : usually empty because the browser automatically sends a GET request with an empty body when you're only asking for the information at a specific web address)
Step 4: The server handles the request and sends back a response.
Congratulations! You have made it this far. Now, let’s elaborate on how the server processes your HTTP request.
Request Processing: based on the HTTP method(eg., GET, POST, etc sent by the request it analyzes the action to be taken.
Resource Retrieval: for static content , the server just locates the file.
In the case of dynamic content , it executes the necessary code needed to generate the content.
Response Generation : The server crafts the HTTP response message, which includes:
3.1 Status Line : Indicates the success or failure of the request
3.2 Response Headers : Provides additional information such as content type, server info, caching instructions, etc.
3.3 Response Body : The servers send the HTTP response message over the secure TCP connection .
Step 5 : The server sends the HTTP response containing the page content.
The response body mentioned above is the HTTP response sent by the server that indicates the status of the request .
200 for success
301 or 302 for error code
4xx/5xx for client or server errors
NOTE : The response body contains the data needed to display the webpage.
Step 6 : The browser renders and displays the HTML content.
The initial response from the server contains the HTML code that helps us to build the initial structure of the webpage .
Separate requests are made for additional resources like images, which are then incorporated into the webpage based on the instructions in the initial HTML.
So this is how ladies and gentlemen, our internet works under the hood. Please feel free to type in your favorite website’s name and go for an HTTP marathon.
Also, feel free to drop your valuable comments. Happy learning! 😁