DEV Community

Santhoshi Mary A
Santhoshi Mary A

Posted on

How a request originates from cllient and reaches the server

A precise series of events is triggered in milliseconds each time you hit Enter on a URL. This is the entire journey, reduced to what really counts.

  1. Parsing URLs
    The browser starts determining where to send the request after breaking down https://www.example.com/products into three parts: protocol (https), domain (www.example.com), and path (/products).

  2. DNS Resolution
    Instead of a domain name, the browser requires an IP address. After checking its cache and the OS cache, it queries a DNS Recursive Resolver, which returns the IP after tracing the response up through Root, TLD, and Authoritative name servers.

Browser -> Resolver -> Root NS -> TLD NS -> Authoritative NS
|
93.184.216.34 <-----+
3.TLS Handshake (HTTPS only)
For secure connections, both sides negotiate encryption. The server presents its SSL certificate, they agree on a cipher, and a shared session key is derived. All further communication is encrypted.

4.HTTP Request and Methods
The browser sends the actual request:
The HTTP method tells the server what action to perform on the resource.
HTTP Methods Explained
Method

GET Retrieve a resource

POST Create a new resource

PUT Replace a resource entirely

PATCH Partially update a resource

DELETE Remove a resource
5.Idempotency: An Essential Idea in API Design
Idempotency is the ability of the server to produce the same result when the same request is made once or several times. In distributed systems, this is crucial because servers need to behave consistently, networks fail, and clients retry.

If making a request ten times has the same impact on the server state as making it just once, then it is idempotent.
Idempotency by Method
Idempotent Methods:
GET
PUT
DELETE
Non-Idempotent Methods:
POST (usually)
PATCH (depends)

6.The request is processed by the server

The server

gets the request
Verifies authenticity
executes backend logic
database queries when necessary
gets ready to respond
7.Server Sends HTTP Response
With:

Status code
Headers
Body (HTML/JSON/etc.)
8.The response is rendered by the browser.

The web browser

Parses HTML
uses CSS
JavaScript is executed
makes more API requests
shows the user the page

Top comments (0)