HTTP headers reference
Written for the moment a header is misbehaving, not for completeness: what each one does, and the mistake usually hiding behind it.
Cache-ControlbothWho may cache the response and for how long — the header that decides whether your deploy shows up.
ETagresponseA fingerprint of the response body, so the next request can ask “has it changed?” and get a tiny 304 instead of the whole thing.
Last-ModifiedresponseWhen the resource last changed, for If-Modified-Since revalidation. The second-choice ETag.
ExpiresresponseThe legacy freshness header. Cache-Control: max-age wins whenever both are present.
AgeresponseHow many seconds a cached copy has been sitting in the CDN. The debugging header for “why am I seeing stale content”.
Content-TypebothWhat the body IS. Wrong or missing, and browsers guess, APIs 415, and JSON arrives as text.
AcceptrequestWhat the client wants back. Content negotiation's polite request — servers may ignore it.
AuthorizationrequestThe credential: Bearer tokens, Basic auth. The header that must never end up in logs or URLs.
WWW-AuthenticateresponseSent with a 401 to say which auth scheme is expected. What makes the browser's Basic-auth prompt appear.
CookierequestEvery cookie the browser holds for this origin, on every request. The reason cookie bloat slows sites.
Set-CookieresponseCreates or updates a cookie. The attributes are the security model: HttpOnly, Secure, SameSite.
LocationresponseWhere to go next: the target of every 3xx redirect, and where a 201 says the new thing lives.
HostrequestWhich site on this IP the request is for. Mandatory since HTTP/1.1; virtual hosting depends on it.
User-AgentrequestWhat the client claims to be. Useful for logs, unreliable for decisions — everything lies for compatibility.
RefererrequestThe page the request came from — misspelled in the RFC forever. Controlled by Referrer-Policy.
Referrer-PolicyresponseHow much of your URLs leak to other sites when users click away. strict-origin-when-cross-origin is the sane default.
OriginrequestScheme + host + port of the requesting page. The input CORS decisions are made on.
Access-Control-Allow-OriginresponseThe CORS verdict: which origin may read this response from JavaScript.
Access-Control-Allow-MethodsresponseWhich verbs the cross-origin caller may use, answered on the preflight OPTIONS.
VaryresponseWhich request headers change the response — so caches keep separate copies per variant.
Accept-EncodingrequestWhich compressions the client understands: gzip, br, zstd.
Content-EncodingresponseHow the body is compressed. Set it wrongly by hand and every client sees garbage bytes.
Content-LengthbothBody size in bytes. Lying about it hangs connections; chunked transfer omits it.
Content-DispositionresponseDisplay inline, or download with this filename — the header behind every “Save as” name.
Strict-Transport-SecurityresponseHSTS: this site is HTTPS-only; browsers must not even try HTTP for max-age seconds.
Content-Security-PolicyresponseThe allowlist of what the page may load and run. The strongest XSS mitigation there is, and the easiest header to break your own site with.
X-Frame-OptionsresponseMay this page be put in an iframe? DENY stops clickjacking; superseded by CSP frame-ancestors but still widely sent.
X-Content-Type-Optionsresponsenosniff: trust my Content-Type, never guess. One value, no downside, always send it.
Retry-AfterresponseWhen to come back, on a 429 or 503. Clients that honour it get unbanned faster than clients that hammer.
X-Forwarded-ForrequestThe client IPs a request passed through on its way in. Whatever the outermost client CLAIMS, plus each proxy's addition.
ForwardedrequestThe standardised replacement for the X-Forwarded-* family, less widely deployed than any of them.
If-None-Matchrequest“Only send the body if the ETag changed.” The request half of 304 revalidation.
If-Matchrequest“Only apply this write if the ETag still matches” — optimistic locking over HTTP; 412 when it does not.
RangerequestAsk for a byte slice of a file. Video seeking and resumable downloads are built on it.
Transfer-Encodingresponsechunked: the body streams in pieces of unknown total size. Mutually exclusive with Content-Length.
LinkresponseMachine-readable relations: pagination (rel=next), preload hints, canonical URLs.