Headers and representations

Response headers

Read response headers that describe body content, redirects, caching, cookies, and the server's instructions to the client.

8 minute lesson

~~~

Response headers describe the returned representation and how to handle it.

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Cache-Control: max-age=300

Content-Type describes the body. Content-Encoding says the body was compressed. Content-Length gives its byte length when known.

Location points to another URL, usually with a redirect or 201 Created response. Set-Cookie asks a browser to store a cookie. Cache-Control, ETag, and Last-Modified guide caches.

Security headers can restrict what a browser may do with the response. We will cover those later.

Inspect headers in the Network panel instead of guessing. A server, reverse proxy, CDN, or hosting platform may add or replace them.

Lesson completed