![istockphoto-1084095896-612x612](https://hackmd.io/_uploads/B1D0jiPd0.jpg) # Behind the Scenes: What Happens When You Enter a URL Ever typed a web address into your browser and wondered what happens next? It might seem like magic, but there's a complex journey that occurs behind the scenes that delivers the content you see on your screen. Let's delve into the journey a web request takes from the moment you hit enter: **Scene 1: The Address Lookup** 1. **DNS Request:** When the user types "https://www.google.com" (the URL), your browser doesn't understand this human-readable format. It needs an IP address, a unique numerical identifier for computers on the internet. So, your browser sends a DNS(Domain Name System) request to a DNS server. The DNS server is like a giant book for the internetk, translating website name (domains) into their corresponding IP addressses. The translating happens through a hierarchical process: a. **Local DNS Resolver:** Hitting `enter` does not go striaght to the internet. it first searches the local DNS resolver(provided by your internet service provider). The resolver might have a cache of recently looked up domains and their corresponding IP addresses.If the requested domain is in the cache then the IP address is retrieved and passed on to the browser. b. **Recursive vs. Iterative Resolution:** if the local resolver doesn't have the IP address, it initiates a recursive or iterative resolution process: * Recursive Resolution:(most common approach) The local resolver acts on your behalf, contacting a series of DNS servers until it finds the one that holds the IP address for the requested domain. it involves: * Root Nameserver: The local resolver first queries a root nameserver. See this as the internet switchboard with the addresses of all Top-Level Domain (TLD) nameservers(like .com, .org, .net). * TLD Nameserver: Based on the TLD in the URL (eg: ".com" for Google), the root nameserver directs the resolver to the appropriate TLD nameserver. * Authoritative Nameserver: Finally, the TLD nameserver points the resolver to the authoritative nameserver for the specific domain (eg., Google's nameservers). This server holds the actual IP address for "https://www.google.com". * Iterative Resolution: (Less common) The local resolver takes a more hands-on approach. It contacts each server in the hierarchy (root, TLD, authoritative). c. **Response and Caching:** Once the local resolver obtains the IP address, it sends it back to your browser. The resolver may cache th IP address if not present in the local DNS to speed up search process. ![dnsworks](https://hackmd.io/_uploads/BJ5htNcOC.jpg) 2. **TCP/IP:** With the IP address in hand, your browser initiates communication using the TCP/IP(Transmission Control Protocol/Internet Protocol) protocol suite. TCP/IP ensures data is broken down into packets, sent over the internet, and reassembled correctly on the receiving end. This is the fundamental suite that governs communication across the internet. This is like a common language for devices to exchange data reliably and efficiently. ![requestandresponse](https://hackmd.io/_uploads/rkLjcNqdC.png) **Scene 2: Security Check and Traffic Management** 3. **Firewall:** Before reaching its destination, the data might pass throught a firewall, a security guard that filters incoming and outgoing traffic based on pre-defined rules. This helps protect your computer and the server from malicious activity. 4. **HTTPS/SSL:** For secure websites(indicated by "https" in the URL), the data is encrypted using HTTPS(Hypertext Transfer Protocol Secure) and SSL(Secure Sockets Layer) protocols. This scrambles the information, making it unreadable to anyone intercepting it. 5. **Load Balancer:** For high-traffic websites like Google, a load balancer might be involved. This acts as a traffic director, distributing incoming requests across multiple web servers to ensure smooth performance and prevent overloading any single server. **Scene 3: Delivering the Content** 6. **Web Server:** The request finally reaches the web server, which houses the websites's files. it interprets the request, locates the relevant files (HTML, CSS, JavaScript, images, etc.) and prepares a response. 7. **Application Server**: In some cases, the web server might hand off tasks to an application server. This server handles complex logic, interacts with databases, and generates dynamic content based on user input or other factors. 8. **Database:** If the requested content requires information from a database (product listings, user accounts, etc.), the application server might interact with a database server to retrieve the data. **Scene 4: Rendering the page:** 9. **Response Received:** The web server sends the response back to your browser. This response includes the HTML code for the webpage, along with any additional files like images and scripts. ![HTTP_ResponseMessageExample](https://hackmd.io/_uploads/rkpYoV9uA.png) 10. **Rendering:** Your browser receives the data, parses the HTML code, and uses the included CSS and JavaScript to format and display the content on your screen. ## Pictorial Representation of What happens Under the Hood, When "https://www.google.com" is typed in browser and `enter` key is pressed ![final server](https://hackmd.io/_uploads/B1z-Gw5dA.png) [Image link](https://www.canva.com/design/DAGLjmhDj14/c15Ot28yMIkMY2lk0Sigcw/view?utm_content=DAGLjmhDj14&utm_campaign=designshare&utm_medium=link&utm_source=editor)