Sobes.tech
Middle

What happens when you enter the address google.com in the browser?

sobes.tech AI

Answer from AI

  1. URL Parsing: The browser analyzes the entered URL, determining the protocol (HTTPS), domain name (google.com), and port (default 443 for HTTPS).
  2. Cache Lookup: The browser checks its own DNS cache to find the IP address corresponding to google.com.
  3. Query to Resolver: If no record is found in the cache, the browser requests the IP address from the DNS resolver configured in the operating system.
  4. Recursive DNS Query:
    • The resolver queries root DNS servers.
    • Root servers point to TLD servers for .com.
    • TLD servers for .com point to authoritative DNS servers for google.com.
    • The authoritative DNS servers for google.com return the IP address(es) of Google's web server.
  5. Establishing TCP Connection (SYN/ACK): The browser initiates a TCP connection with the obtained IP address using a three-way handshake (SYN, SYN-ACK, ACK).
    // Client --> Server: SYN
    // Server --> Client: SYN-ACK
    // Client --> Server: ACK
    
  6. Establishing TLS/SSL Connection: Since the protocol is HTTPS, a TLS/SSL handshake occurs to establish a secure, encrypted connection. Both parties exchange certificates and generate session keys.
  7. Sending HTTP/S Request: The browser sends a GET request to the Google server to retrieve the homepage.
    GET / HTTP/1.1
    Host: google.com
    User-Agent: <browser info>
    Accept: text/html,...
    
  8. Server Processing the Request: The Google web server (likely through a load balancer) receives and processes the request, possibly interacting with internal services.
  9. Sending HTTP/S Response: The server forms an HTTP/S response, including a status code (e.g., 200 OK) and the response body (HTML code of the page).
    HTTP/1.1 200 OK
    Content-Type: text/html; charset=UTF-8
    Content-Length: <content size>
    // ... other headers
    // Response body (HTML)
    
  10. Page Rendering: The browser receives the HTML, parses it, and constructs the DOM tree.
  11. Resource Loading: The browser detects links to CSS, JavaScript, images, and other resources in the HTML. For each resource, steps 2-9 are performed (or existing connections are used), requests are sent, and resources are loaded.
  12. Building CSSOM: The browser parses CSS and constructs the CSS Object Model.
  13. Building Render Tree: The DOM and CSSOM are combined to build the render tree.
  14. Layout (Reflow): The browser calculates the geometric sizes and positions of each element on the page.
  15. Painting: Elements are rendered on the screen.
  16. JavaScript Execution: The browser executes JavaScript code, which may modify the DOM, CSSOM, and initiate further actions.
  17. Closing the Connection: After data transfer is complete, the TCP connection may be closed or kept alive for subsequent requests (keep-alive).