HTTP Request and Response
Try it: HTTP Request and Response
What really happens when a browser fetches a URL: DNS lookup, TCP connection, the exact HTTP/1.1 request text, how the server picks a status code (200, 301, 304, 404, 405, 500), and how a cache with max-age and ETag avoids or shortens the next request.
How it works
- Check the browser cache: a copy younger than its max-age is used with no request at all; an older one is revalidated with If-None-Match.
- Look up the host name to get an IP address (DNS), then open a TCP connection to port 80 (http) or 443 (https).
- Send the request line (method, path, HTTP/1.1), one header per line, a blank line, and the body if any.
- The server routes the path: missing → 404, wrong method → 405 with Allow, crash → 500, moved → 301 with Location, matching ETag → 304, otherwise 200 with Content-Type, Content-Length, ETag and Cache-Control.
- The client follows a 301 to its Location, stores a cacheable 200, or reuses its cached body after a 304.
Default run (17 steps): The browser will request GET http://data.pr4e.org/page1.htm, then visit it again 90 s later. Browser cache: on. … Done. Visit 1: 200; Visit 2: 304.
Simplified: A toy browser and one toy server on a simulated clock (fixed per-phase delays). The DNS resolver is a three-entry table, TLS is a single step with no real cryptography, every request opens a new connection (Connection: close), only 200 responses to GET are cached, and ETags are a toy hash of the body. No real network traffic is sent.
Loading the simulation…