How the Internet Brings Websites to Your Screen
A Simple Guide to What Happens When You Visit a Website
We often interact with web browsers and search for something on the internet but have we ever thought what happens when that action button is clicked? We call it HTTP request with all the required information like URL, Request Body, Header, etc.
URL has something called domain name (whoisaviraj.com) which we often type or remember but system understands the IP addresses (100.101.2.34) which can be tough or nearly impossible to remember. IP addresses are basically an identifier that allows data to be sent between devices on the network. Every domain name is assigned to an IP address and are mapped in the DNS server. The process of getting the IP address from the domain name is called DNS Resolution.
DNS Working
I will try to give a simple explanation of how DNS resolution works, step by step:
You type a website address
When you enter a website like whoisaviraj.com in your browser, it needs to find the exact server (by its IP address) where the website is hosted.Browser checks its cache
Your browser first checks its memory to see if it already knows the IP address for whoisaviraj.com. If it finds it, the process ends here, and the website loads.Operating system checks its cache
If the browser doesn't have the information, your computer’s operating system (OS) looks in its own DNS cache for the IP address.Query goes to the DNS resolver
If the OS doesn't have the IP address, it sends a request to a DNS resolver. This is usually managed by your Internet Service Provider (ISP) or a public DNS service like Google DNS or Cloudflare DNS.Resolver checks its cache
The resolver looks in its own cache to see if it has the IP address. If it does, it sends the IP address back to your computer.Resolver contacts the root DNS server
If the resolver doesn’t have the answer, it asks one of the root DNS servers. These servers are like a global directory and direct the resolver to the right place to find more information.Resolver contacts the TLD server
The root server points the resolver to the Top-Level Domain (TLD) server based on the domain extension, such as .com, .in, .ai The TLD server then points the resolver to the server responsible for the domain name.Resolver contacts the authoritative DNS server
The resolver now contacts the authoritative DNS server, which holds the actual information about the domain. This server provides the IP address for whoisaviraj.com.Resolver sends the IP address to your computer
The resolver sends the correct IP address back to your computer. This IP address tells your browser where to find the website.Browser loads the website
Using the IP address, your browser connects to the web server hosting whoisaviraj.com, and the website appears on your screen.
The DNS resolution process is like finding a contact in a phonebook. It takes a domain name, checks multiple sources for its matching IP address, and directs your browser to the right server.
Transport Layer Overview
Once the browser has the IP address of whoisaviraj.com, it needs to establish a connection with the server hosting the website. This happens through the Transport Layer. Its job is to ensure reliable communication between your device and the server. For websites, the TCP (Transmission Control Protocol) is commonly used.
TCP Handshake
Before any data is sent, the browser and the server need to establish a reliable connection. This is done through the TCP three-way handshake:
SYN (Synchronize)
Your browser sends a message to the server saying, “Hey, I’d like to start a connection.”SYN-ACK (Synchronize-Acknowledge)
The server responds with, “Sure, let’s connect! I’m ready.”ACK (Acknowledge)
Your browser replies, “Great, I’m ready too!”
At this point, a stable connection is established. It’s like introducing yourself before starting a conversation.
TLS Handshake (for HTTPS)
Since whoisaviraj.com likely uses HTTPS (secure connection), the browser and server now perform a TLS (Transport Layer Security) handshake to ensure the connection is encrypted and private.
Hello Messages
The browser says, “Hello! I want a secure connection, and here are the encryption methods I support.”
The server replies, “Hello! Let’s use this specific encryption method, and here’s my certificate proving I’m the real whoisaviraj.com.”
Certificate Validation
The browser checks the server’s certificate to confirm it’s authentic and issued by a trusted authority.Key Exchange
Both the browser and the server agree on a unique encryption key to secure the connection.
Once the handshake is complete, all data exchanged between the browser and the server is encrypted.
Data Transfer
Now that the connection is secure, the browser requests the actual content of whoisaviraj.com.
HTTP Request
The browser sends an HTTP request to the server, asking for the homepage of the website.
Example: “GET / HTTP/1.1” (This means, “Please send me the homepage.”)Server Response
The server processes the request and sends back the requested data, including the HTML, CSS, JavaScript, images, and other resources.Rendering the Page
The browser takes the data, renders the page, and displays whoisaviraj.com on your screen.
Server’s Role
The server hosting whoisaviraj.com plays a key role:
Listening for Requests: The server is always online and waiting for incoming requests from visitors.
Processing Requests: It processes your browser’s request and prepares the data to send back.
Sending Responses: It sends the website files (HTML, CSS, etc.) to the browser over the secure connection.
After the data is delivered, the connection stays open for a short time in case more requests are needed (like when you click a link). Eventually, the TCP connection closes.
The entire process happens in seconds, allowing us to browse the internet smoothly and securely!