The Lifecycle of an HTTP Request: From Client to Server and Back

By Guilherme Luiz Maia Pinto
Picture of the author
Published on
HTTP Request Lifecycle Banner

Introduction

Every time you click a link, submit a form, or load a webpage, a complex yet seamless process takes place behind the scenes: the HTTP request lifecycle. This process connects users to servers, enabling the transfer of data that powers the web. In this article, we break down the lifecycle step by step.


1) Request Initialization

The journey begins when a user interacts with a client application (for example, typing https://example.com and pressing Enter). The browser prepares an HTTP request that includes:

  • HTTP Method: the action (GET, POST, PUT, DELETE)
  • URL: the resource location (for example, https://example.com)
  • Headers: metadata such as Content-Type, Authorization, Accept-Language
  • Body: data sent to the server (mainly with POST/PUT/PATCH)

2) DNS Resolution

Before the request reaches the server, DNS resolves the human-readable domain into an IP address.

Key steps:

  1. Local cache check (browser/OS/DNS cache)
  2. Recursive resolver query (ISP or public DNS like 8.8.8.8)
  3. Authoritative server query (finds the final IP for the domain)

3) TCP/IP Connection (and TLS)

With the IP address known, the client creates a TCP connection using the three-way handshake:

  1. SYN: client asks to synchronize
  2. SYN-ACK: server acknowledges
  3. ACK: client confirms; connection established

For HTTPS, a TLS handshake runs to encrypt the session.

Key protocols:

  • TCP: reliable, ordered transport
  • TLS/SSL: encryption and integrity for HTTPS

4) Request Transmission

The browser sends the HTTP request over the established connection, including method, path, headers, and optionally a body. Intermediaries (proxies, CDNs) may handle or forward the request.


5) Server Processing

When the request reaches the server (for example, NGINX or Apache in front of an application):

  1. Routing: resolve which app/route should handle the request
  2. Business logic: execute handlers, call services/DBs (for example, Node.js/Express, Django, Spring)
  3. Response generation: prepare the HTTP response with:
    • Status code (200 OK, 404 Not Found, 500 Internal Server Error)
    • Headers (for example, Content-Type, Cache-Control)
    • Body (HTML, JSON, image, etc.)

6) Response Transmission

The server sends the response back over the same TCP connection. Large payloads may use chunked transfer encoding. CDNs and proxies can cache responses based on headers.


7) Browser Rendering

Once the response arrives, the browser renders it:

  1. HTML parsing → build the DOM
  2. CSS and JS fetching/execution → build the CSSOM and run scripts
  3. Rendering and painting the final view

Additional requests (images, CSS, JS) are fetched as needed—often in parallel.


8) Connection Closure or Reuse

After the transaction, the connection may be:

  • Closed (for example, Connection: close)
  • Reused via HTTP Keep-Alive for subsequent requests to the same origin

Modern browsers also use HTTP/2 or HTTP/3 features (multiplexing, header compression) to optimize many requests over fewer connections.


Conclusion

The HTTP request lifecycle showcases the tight collaboration between DNS, TCP/TLS, HTTP, servers, and browser engines. Understanding these steps helps developers optimize performance, reliability, and security, resulting in faster and more robust user experiences.

Stay Tuned

Want to become a Software Engineer pro?
The best articles and links related to web development are delivered once a week to your inbox.