Understand the HTTP request-response cycle
Learn the roles, direction, and observable boundaries of a single HTTP request and response.
- messages
- request response
One exchange has two messages
An HTTP exchange begins when a client sends a request. The server processes that request and sends a response. Intermediaries such as proxies or caches can take part, but each hop still observes request and response messages with defined semantics.
GET /guides/cache-validation HTTP/1.1
Host: httpclarity.com
Accept: text/html
Expected result: the request identifies the GET method, a target path, and
the representation formats the client can accept. It does not contain a response
status.
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 1234
Expected result: the response reports an outcome with status 200 and
describes the enclosed representation with response fields.
Observe before you explain
Developer tools can show the messages visible to that browser. A command-line client can show a different path through caches, proxies, DNS, or TLS. Record the actual request and response first, then identify which layer could have produced the observation.
Keep the direction explicit
- Methods and request targets belong to requests.
- Status codes belong to responses.
- Fields can appear in requests, responses, or both depending on their defined semantics.
- A browser policy can prevent page JavaScript from reading a response even when the network exchange succeeded.
