What Happens When You Enter in A Browser?: 2.1 URL Parsing
What Happens When You Enter in A Browser?: 2.1 URL Parsing
1 Overview
When a user types https://google.com (or just google.com) into a browser, a sequence of steps
spans from URL parsing and cache checks on the client side, through DNS resolution, network
transport (TCP/TLS), the HTTP request/response exchange, server-side processing in Google’s
global infrastructure, and finally browser rendering. Below is a concise yet comprehensive description
of these phases, followed by a crisp bullet-point summary.
• The URL is split into: scheme (https), host (google.com), port (default 443), and path (/).
• HTTP Cache: If a previous visit exists, the browser checks whether it can reuse a cached HTML
resource or must revalidate via If-None-Match (ETag) or If-Modified-Since.
3 DNS Resolution
3.1 Local and Recursive Resolver
• The browser calls the OS stub resolver (e.g., getaddrinfo), which checks the local hosts file and
then the OS DNS cache.
• If not found locally, the stub forwards the query to a recursive DNS server (e.g., ISP or public
DNS).
2. .com TLD Servers provide referrals to Google’s authoritative name servers (ns1.google.com,
etc.).
3. Google Authoritative Servers return one or more A/AAAA records (e.g., 142.250.x.x),
along with a TTL (e.g., 300 s).
1
Each resolver along the chain caches intermediate responses according to the TTL. Once the
browser has an IP, it proceeds to establish a TCP connection.
• Once the MAC address is known, the client can send IP packets toward the gateway (and ulti-
mately to Google’s server) over Ethernet or Wi-Fi.
2. Server → Client (SYN-ACK): Google’s server responds with SYN+ACK, acknowledging the
client’s SYN.
3. Client → Server (ACK): The client sends an ACK, completing the handshake.
During this exchange, TCP options such as MSS, Window Scale, SACK, and Timestamps are
negotiated. The connection then enters the established state.
• Uses X.509 certificates, where google.com presents a certificate chain signed by a trusted CA.
• HSTS (HTTP Strict Transport Security) ensures the browser does not downgrade to HTTP.
2. ServerHello: The server selects a cipher suite, returns its random nonce and ephemeral public
key (KeyShare).
3. Certificate & CertificateVerify: The server sends its certificate chain (e.g., *.google.com)
and a signature over earlier handshake messages.
4. Client Finished: The client verifies the server certificate (chain of trust, domain match, validity
date) and sends a Finished message.
2
At this point, both sides derive symmetric keys for encrypting application data. If session resumption
is possible, the client may use a pre-shared session ticket (0-RTT) to send early data (e.g., HTTP
GET) on the first flight.
• The client sends an initial SETTINGS frame, and then a HEADERS frame on Stream 1 containing
pseudo-headers:
:method = GET
:scheme = https
:authority = google.com
:path = /
user-agent = Mozilla/5.0 ...
accept = text/html,...
accept-encoding = gzip, br
• Edge Load Balancer: Terminates TLS (often via specialized hardware), then proxies the de-
crypted HTTP/2 request to a local front-end server cluster.
• Cache Check: If the homepage HTML is cached in the edge, it can send a cached response;
otherwise, it forwards to a search-frontend service.
• Front-End Server: Composes the HTML (e.g., localized template, search box), sets appropriate
response headers (e.g., Cache-Control: private, max-age=0), compresses with Brotli, and
sends back the HTTP/2 HEADERS+DATA frames.
• content-encoding: br (Brotli-compressed)
3
7.2 TCP/TLS Flow Control
• The server’s TLS layer splits the compressed HTML into TLS records, which are sent in TCP
segments.
• The client’s TCP stack acknowledges received segments; congestion control (Slow Start → Con-
gestion Avoidance) adjusts the send window.
• Once all HTML bytes are received and acknowledged, the TCP connection remains open (Keep-
Alive) for 90 seconds, allowing subresource requests to reuse it.
• Encountering a <link rel="stylesheet"> triggers a fetch (over the same HTTP/2 connection)
for CSS; the parser may wait (render-blocking) until critical CSS arrives if needed.
• <script> without async/defer blocks parsing until the script is fetched and executed; async/defer
scripts allow parsing to continue.
• Style recalculation happens once CSS is available: each DOM element is matched against CSS
selectors to compute its styles.
• Layout (Reflow): Computes geometry (width, height, position) for each render node based on
the CSS box model, flex, grid, etc.
• Paint: Each render node is drawn into GPU layers (bitmaps), including text, backgrounds,
borders, and images.
• Compositing: The GPU compositor merges layers into final screen pixels.
• window.onload fires after all subresources (images, fonts, CSS) are fully loaded.
• The event loop processes microtasks (Promise callbacks) between rendering frames; forced reflows
(e.g., reading offsetWidth) can stall rendering.
4
9 Subresource Fetching & Caching
9.1 Additional Resources
• Images (Logo): Fetched via HTTP/2 on the same connection; served with long TTL (e.g.,
Cache-Control: public, max-age=86400, immutable).
• JavaScript Bundles: May load additional JS modules dynamically; each uses the existing
connection or opens new ones if cross-origin (e.g., fonts.gstatic.com).
• Web Fonts: Trigger DNS → TCP → TLS → HTTP to fonts.gstatic.com, then download a
WOFF2 (Brotli-compressed) font file; fonts may cause FOIT/FOUT.
• HTTP/2 Multiplexing: All subresources for google.com share the same TCP/TLS connection,
with multiple concurrent streams (no head-of-line blocking at HTTP layer).
• HTTP/3 (QUIC): If supported, the browser may use QUIC over UDP, combining TLS 1.3 with
multiplexed streams and 0-RTT resumption, reducing handshake overhead.
• Web Vitals: Largest Contentful Paint (LCP), Cumulative Layout Shift (CLS), First Input Delay
(FID) are measured and reported via navigator.sendBeacon() or XHR.
• Error Reporting: JS runtime errors or network failures are logged to Google’s telemetry services
for real-user monitoring (RUM).
11 Bullet-Point Summary
1. URL Parsing & Caching
2. DNS Resolution
– Stub resolver checks hosts file & OS cache; if missing, queries recursive DNS.
– Recursive lookup: root → .com TLD → Google’s authoritative servers → returns IP(s) (e.g.,
142.250.x.x).
– Caches intermediate results (TTL-based).
3. TCP Handshake
5
– Client sends SYN; server replies SYN-ACK; client replies ACK.
– Negotiates TCP options (MSS, window scaling, SACK, timestamps).
6. Server-Side Processing
8. Browser Rendering
– Images (logo), JS bundles, and fonts are fetched over HTTP/2 (same connection) or new
connections if cross-origin.
6
– Static assets get long TTL (Cache-Control: public, max-age=86400, immutable); home-
page HTML gets revalidated each load.
– HTTP/2 multiplexes multiple streams on one TCP; HTTP/3 (QUIC) may be used if sup-
ported, combining TLS 1.3 with UDP.
– Browser records timing (DNS, TCP, TLS, TTFB, DOMContentLoaded, load) via the Naviga-
tion Timing API.
– Web Vitals (LCP, CLS, FID) are measured and reported for performance analytics.
– Errors or performance issues are logged via beacons or XHR to Google’s telemetry endpoints.
End of Document