Typing a URL in the browser triggers a complex chain of events involving the browser, network, and server. Here’s a step-by-step breakdown:
1️⃣ Browser Checks Cache
- The browser checks if the page is already cached (HTML, CSS, JS, images).
- If cached and valid → serves it without a network request.
- Otherwise → proceeds to network request.
2️⃣ DNS Lookup
- The browser resolves the domain name (e.g.,
example.com) to an IP address using DNS. - Checks local cache → OS cache → router → ISP DNS servers.
3️⃣ TCP Connection
- Browser initiates a TCP handshake with the server (IP from DNS).
- Usually uses port 80 for HTTP or 443 for HTTPS.
4️⃣ TLS/SSL Handshake (for HTTPS)
- Establishes a secure encrypted connection between browser and server.
- Certificates are verified to ensure authenticity.
5️⃣ HTTP Request
- Browser sends an HTTP request to the server:
- Method:
GET - Headers:
User-Agent,Accept,Cookiesetc. - URL path, query params
- Method:
6️⃣ Server Processing
- Server receives request, processes it, and generates a response:
- Could be static HTML or dynamically generated content (via Node, PHP, Python, etc.)
- Includes status code (200, 404, 500, etc.)
- Response headers (
Content-Type,Cache-Control, etc.)
7️⃣ Response Sent to Browser
- Browser receives HTML first
- Starts parsing HTML and discovers CSS, JS, images → sends additional requests (HTTP/2 can handle multiple in parallel)
8️⃣ Browser Rendering
- HTML Parsing → DOM tree
- CSS Parsing → CSSOM tree
- JS Execution → may modify DOM or CSSOM
- Render Tree → layout calculation → painting on screen
- Repaints/Reflows as needed (if JS modifies layout)
9️⃣ Final Page Load
- Event listeners (
DOMContentLoaded,load) are triggered. - Page becomes interactive.
- Browser may continue fetching deferred resources like images, videos, or API calls.
⚡ In short:
Typing a URL starts from DNS resolution, establishes a TCP/HTTPS connection, sends an HTTP request, gets a response, and the browser parses HTML, CSS, and JS to render the page.
It’s a complex pipeline involving caching, networking, security, and rendering.