Understand the HTTP request-response cycle
Learn the roles, direction, and observable boundaries of one request and its associated responses.
- messages
- request response
One request can have more than one response
An HTTP exchange begins when a client sends a request. The server processes that
request and sends exactly one final response. Before it, the server can send zero
or more informational responses with 1xx status codes. 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.
An informational response such as 100 Continue reports progress before the
final response. It does not replace the final response, and a single request can
therefore have multiple associated response messages.
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.
