So, we type a URL in the browser like www.google.com and it gives us a nice web page almost instantly - That's lightning fast ! Ever wondered what happens when you type a web address into your browser's address bar and hit Enter ? Fasten your seatbelt and let's embark on this incredible journey into the world of the internet.
STAGE 1 :The Quest Begins (Typing the URL) : https://www.google.com
URL ( Uniform Resource Locator ) could be for a website, a web application, or any resource on the internet. It's job is to locate the website resource for us - It has 3 parts :
a. scheme : http or https ( secure http)
b. domain eg. like google.com
c. path on the server to the requested resource eg. index.html
STAGE 2 : Summoning the DNS ( name to IP resolution ) : Your computer sends a request to the domain name system (DNS) server which serves as an address book for all domain names. This then sends back the exact IP address of the server which google.com points to. Browser checks cache for DNS entry one by one until it finds it :
If this does not work then the browser asks its local DNS resolver, which is like a librarian, to find the IP address of the domain you want to visit. The DNS resolver checks its records to see if it has the IP address already. If it does, it gives it to the browser right away.
If the DNS resolver doesn't have the IP address, it asks a root name server, which is like a directory of all the DNS resolvers in the world. The root name server tells the DNS resolver the address of the TLD ( top level domain ) name server for the domain you want to visit.
The TLD name server then tells the DNS resolver the IP address of the domain. The DNS resolver then gives the IP address to the browser, and the browser can finally load the website. If not then TLD name server responds with the address of the authoritative name server for the domain which in turn responds with the IP address for the domain to the browser for loading the website.
STAGE 3: Opening the Magic Portal (Establishing a TCP Connection ) :
Your browser initiates a TCP/IP 3-Way Handshake (SYN, SYN-ACK, ACK) to establish a connection.
STAGE 4: The Enchanted Request ( Sending an HTTP Request ) :
Once the handshake is complete, the browser can send a request for the web page it wants to access. This request is sent using TCP, which ensures that the request is transmitted reliably and in the correct order.
STAGE 5: The Castle Guardian's Response (Sending an HTTP Response)
The web server, being kind and generous, reads your letter (HTTP request) and sends a package back (HTTP response).
The server responds with status codes:
STAGE 6: Unwrapping the Treasure ( Rendering the Web Page) :
STAGE 7: Interacting with the Treasure (User Interaction) :
Now, you're not just a spectator; you're part of the adventure! You click on links, fill out forms, and explore the treasure chest further. Each action you take sends more HTTP requests to the web server, asking for new update.
STAGE 8: Keeping Secrets Safe (Caching) :
Your browser is smart; it keeps some treasures (images, styles) in a secret cave (cache) so that if you return to the same place, it can quickly show you the familiar treasures without asking the castle guardian (server ) again.
STAGE 9: The Last Supper (Enjoy your web page ) :
And there you have it, the last supper! You've gone from typing a web address to experiencing the magic of the internet. You've unlocked the secrets of the URL journey and witnessed the transformation of a simple click into a captivating web page.
( And you cannot blame me for the slow motion treasure hunt ! )