Middle+
What happens when you make an HTTP request from a browser before receiving a response?
sobes.tech AI
Answer from AI
When a browser makes an HTTP request, several steps occur:
- DNS resolution — the browser converts the domain name into an IP address.
- Establishing a TCP connection — the browser sets up a TCP connection with the server (usually on port 80 or 443 for HTTPS).
- TLS handshake (if HTTPS) — a secure connection is established.
- Sending the HTTP request — the browser constructs and sends the request (method, headers, body).
- Waiting for a response — the browser waits for a response from the server.
During this time, the browser can:
- Render the content already received.
- Perform other requests in parallel (if the browser policy allows).
- Handle user events.
After receiving the response, the browser begins processing:
- Parsing headers and body.
- If it's HTML, starting to build the DOM.
- Loading additional resources (CSS, JS, images).
Thus, between sending the request and receiving the response, network interaction, waiting, and data processing preparation occur.