The server has processed the request—now it needs to send back the result. Without a structured response format, the client wouldn’t know if the request succeeded, what data was returned, or how to interpret it.
An HTTP response is the server’s reply containing: status code (200, 404, etc.), headers (content-type, cache-control), and body (HTML, JSON, etc.).
A typical HTTP response looks like:
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1234
<html>...</html>
- Status Line: HTTP version + status code + reason phrase
- Headers: Metadata (content-type, cache settings, cookies)
- Body: The actual data (HTML page, JSON, image, etc.)
The browser processes the response based on headers and status code.
- Status codes: 2xx (success), 3xx (redirect), 4xx (client error), 5xx (server error)
- Headers tell browser how to handle the response (content-type, caching)
- Body contains the actual resource (HTML, CSS, JS, images)
- Responses can be cached based on cache headers
- Built from: HTTP Request — response is the reply to a request
- Builds into: Browser Rendering — HTML response gets rendered
- Related: HTTP Status Codes — 200, 404, 500, etc.
- Related: HTTP Headers — headers control response behavior
- 204 No Content has no body (valid response)
- 301/302 redirects cause browser to make a new request
- 304 Not Modified uses cached version (saves bandwidth)
- Chunked transfer encoding streams large responses