What Really Happens When You Enter a URL? A Deep Dive into DNS, TCP, and HTTP

This article explains the complete journey of a web request—from DNS lookup and TCP handshake through HTTP exchange, server processing, and browser rendering—while highlighting optimization techniques and the roles of front‑end and back‑end engineers.

Java Backend Technology
Java Backend Technology
Java Backend Technology
What Really Happens When You Enter a URL? A Deep Dive into DNS, TCP, and HTTP

When you type a URL into a browser, a series of steps occur: DNS resolution, TCP connection, sending an HTTP request, server processing, and browser rendering.

Specific Process

1. DNS Resolution

DNS resolution translates a human‑readable domain name into an IP address. The process involves recursive queries from the local DNS server to root, TLD, and authoritative servers, caching results at each level.

DNS Optimization

Multiple lookup steps can be reduced by caching at various levels: browser cache, OS cache, router cache, ISP cache, and authoritative server caches.

DNS Load Balancing

DNS can return different IP addresses based on server load, geographic proximity, or other criteria, enabling load balancing and CDN redirection.

2. TCP Connection

HTTP runs over TCP. A TCP handshake establishes a reliable connection before HTTP data is exchanged.

HTTPS Protocol

HTTPS adds SSL/TLS encryption between the client and server, protecting data in transit. The TLS handshake negotiates encryption keys before HTTP payloads are sent.

3. HTTP Request

The client constructs an HTTP request consisting of a request line, headers, and an optional body.

Request Line

Format:

Method Request-URL HTTP-Version CRLF
GET index.html HTTP/1.1

Request Headers

Headers convey additional information such as Accept, User‑Agent, Cookie, etc. They are used by both browsers and tools like curl.

Request Body

When methods like POST or PUT are used, the body carries data (often JSON) and the Content‑Type header indicates its format.

4. Server Processing and HTTP Response

The server receives the TCP segment, parses the HTTP request, and generates a response consisting of a status code, response headers, and a body.

Status Codes

Three‑digit codes indicate the result: 1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error.

Response Headers

Common headers include Server, Connection, Content‑Type, etc.

Response Body

The body contains the requested resources such as HTML, CSS, JavaScript, images, etc.

5. Browser Rendering

After receiving HTML, CSS, and JS, the browser builds a DOM tree, constructs a render tree, performs layout (reflow), and paints the pixels. Reflow and repaint are performance‑critical, especially on mobile devices.

JavaScript Execution

JS runs on a single thread with an event loop, handling synchronous tasks on the call stack and asynchronous tasks via a task queue.

Web Optimization

Understanding the request lifecycle enables optimization: use caching to avoid network fetches, reduce DNS lookup time, compress responses, and minimize reflow/repaint by limiting DOM changes.

Conclusion

This overview provides a foundational understanding of how browsers retrieve and render web pages, offering practical insights for front‑end and back‑end developers seeking performance improvements.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

TCPHTTPWeb DevelopmentDNSBrowser RenderingWeb Optimization
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.