Technical Articles

What happens when you type a URL into your browser?

0 0
URL stands for Uniform Resource Locator. A URL is the address of a website that you can find in the address bar of your web browser. It helps you navigate to specific websites by pointing to their location.

Example: https://www.debuggersspace.com

DNS and CNAME

DNS (Domain Name System) is like the internet’s phonebook, mapping URLs to their corresponding IP addresses. Each website has a unique IP address, the location of the server hosting the requested website.

CNAME Record: A Canonical Name (CNAME) record is a type of DNS record that maps one domain name to another. This can be helpful when managing multiple services from a single IP address.

Steps: What Happens When You Enter a URL?

  1. DNS Lookup: The browser first checks its cache to find the corresponding IP address of the website. If not found, it queries the DNS server.
    • Browser Cache
    • Operating System’s Cache
    • Router Cache
    • ISP Cache

    If the DNS entry isn’t found in these caches, the ISP’s DNS server initiates a DNS query to find the IP address associated with the domain name.

    Live Example: You can check the IP address of a website by using the terminal command:

    nslookup www.google.com
  2. TCP/IP Connection: After the IP address is found, the browser opens a TCP (Transmission Control Protocol) connection with the web server on port 80 (for HTTP) or port 443 (for HTTPS).Live Example: You can use tools like Wireshark to capture packets and observe the TCP handshake.
  3. TLS Handshake (for HTTPS): If you’re using HTTPS, the browser initiates a TLS (Transport Layer Security) handshake to ensure a secure, encrypted connection.Live Example: When visiting a secure site, click the padlock icon next to the URL in your browser to view the security certificate.
  4. Sending the HTTP Request: The browser sends an HTTP request to the server, asking for the webpage. This request includes headers like browser type, cookies, and the requested page.Live Example: In your browser’s Developer Tools under the Network tab, you can see the HTTP request sent to the server.
  5. Server Processes the Request: The web server processes the request, fetching the requested page or dynamically generating it (if using server-side languages like PHP or Node.js).Live Example: You can observe the server’s response time in the Developer Tools panel. A 200 OK response means the server successfully processed the request.
  6. Server Sends a Response: The server sends back the requested HTML file along with an HTTP status code (e.g., 200 OK, 404 Not Found, 500 Internal Server Error).Live Example: In the Network tab of Developer Tools, you can view the response code and HTML content sent from the server. For instance:
    <html>
    <head><title>Example Domain</title></head>
    <body>
    <h1>Example Domain</h1>
    </body>
    </html>
    
  7. Browser Renders the Page: The browser parses the HTML, CSS, and JavaScript. It builds the DOM (Document Object Model) and renders the page on your screen.Live Example: In the Network tab, you can track the different assets being loaded (like CSS, JS, and images). The rendering engine (WebKit in Safari or Blink in Chrome) paints the elements on the screen.
  8. JavaScript Execution and Event Handling: Once the HTML is rendered, JavaScript is executed. JavaScript can modify the DOM, handle user events, and send additional requests via AJAX.Live Example: You can monitor JavaScript execution in the Console tab of Developer Tools. This shows any errors in scripts or interactions with the page.
  9. Interaction with the Page: After the page is fully loaded, the user can interact with it (e.g., clicking buttons, filling forms). The browser handles these actions and sends any necessary data to the server.Live Example: Inspect how form data is sent by clicking a submit button and observing the Network tab to view the data sent in the request.

Conclusion:

When you type a URL into your browser, a complex sequence of events occurs in the background, involving DNS lookups, TCP/IP connections, HTTP requests, server-side processing, and rendering. This ensures that the webpage is displayed quickly and securely on your screen.

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
temp mail

I’ve been online for more than three hours now, and I haven’t found any articles as fascinating as yours. I think it’s worth it enough. If more bloggers and website owners created content as good as yours, the internet would be far more useful than it already is.

1
0
Would love your thoughts, please comment.x
()
x
× How can I help you?