HTTP Headers: Response Headers
You'll learn how HTTP response headers tell the client critical information about the content being delivered and how to handle it.
What Are Response Headers?
After your browser sends an HTTP request, the server sends back a response — and before the actual content arrives, it sends response headers. These are metadata fields that describe what's coming, how it's formatted, and instructions for caching or processing.
Think of response headers like the label on a shipped package: before you open it, the label tells you what's inside, how heavy it is, and whether it needs refrigeration.
Key Response Headers
Content-Type
This header tells the client what kind of data it's receiving. Is it HTML? JSON? An image?
Content-Type: text/html; charset=UTF-8
Content-Type: application/json
Content-Type: image/png
Without this, your browser wouldn't know whether to render a webpage, parse JSON, or display an image.
Content-Length
This specifies the size of the response body in bytes. It's like knowing how many pages are in a document before you start reading.
Content-Length: 3495
The client uses this to know when it has received the complete response.
Cache-Control
This header instructs the client (and intermediate proxies) how to cache the response. Should the browser store this for later? For how long?
Cache-Control: max-age=3600
Cache-Control: no-cache
Cache-Control: public, max-age=86400
max-age=3600 means "you can reuse this for 3600 seconds without asking me again." no-cache means "always check with me before using a cached copy."
Key Takeaway: Response headers like Content-Type, Content-Length, and Cache-Control provide essential metadata that tells the client how to interpret, handle, and store the server's response efficiently.