Home › Guides › Reference › HTTP Headers Reference

HTTP Headers Reference

Common HTTP request, response, caching, cookie, CORS and security headers, with typical values and the mistakes to avoid.

By the tools4free.dev team · Last reviewed 4 December 2026

How to use this reference

An HTTP header is a name and value pair sent before the body of a request or a response. Headers carry the information that is not the content itself: what format the client wants, how long a response may be cached, who the user is, and which security rules the browser should apply. You can see them in the Network panel of any browser's developer tools, or with a command-line client such as curl -i.

Headers belong to one of two directions. Request headers are sent by the client, such as a browser, to the server. Response headers are sent by the server back to the client. A few, such as Content-Type and Content-Length, describe the body and can appear in both directions. Header names are not case-sensitive. Values often carry parameters after a semicolon, for example text/html; charset=utf-8, or a weighted list, for example q=0.8.

This page groups the headers you will meet most often by purpose: content negotiation, caching, authentication, cookies, cross-origin sharing and security. Each table gives a one-line meaning and a typical value. The core semantics are defined in RFC 9110 (HTTP Semantics) and RFC 9111 (HTTP Caching), and MDN documents the browser behaviour. Custom headers used to begin with X-, but that convention was deprecated in 2012 (RFC 6648), and several widely used headers such as X-Frame-Options and X-Content-Type-Options kept the prefix for historical reasons. For the status codes that go with these headers, see the HTTP status codes reference, and for the values of Content-Type, see the MIME types reference.

The headers you will use most

Content-Type, Accept, Authorization, Cache-Control, Set-Cookie, Location, Access-Control-Allow-Origin and Strict-Transport-Security. If something is cached wrongly, look at Cache-Control and Vary first. If a browser refuses a cross-origin call, look at the CORS headers.

Request headers

These headers tell the server who is asking and what the client can accept.

HeaderWhat it doesExample
HostThe host name, and optionally the port, of the server being requested. It lets one server host many sites.Host: example.com
User-AgentIdentifies the client software making the request.User-Agent: curl/8.0
AcceptThe content types the client can handle, with optional weights.Accept: text/html, application/json;q=0.9, */*;q=0.8
Accept-EncodingThe compression formats the client can decode.Accept-Encoding: gzip, br
Accept-LanguageThe languages the client prefers.Accept-Language: en-GB, en;q=0.8
AuthorizationCredentials that authenticate the client with the server.Authorization: Basic <credentials>
CookieCookies the browser previously received for this site.Cookie: session=abc123
OriginThe origin (scheme, host and port) that started the request. Used for CORS and some forgery checks.Origin: https://app.example.com
RefererThe address of the page that linked to the request. The name is spelt this way because of an early typo.Referer: https://example.com/page
RangeAsks for only part of a resource, for example to resume a download.Range: bytes=0-1023
If-None-MatchMakes the request conditional on the ETag not matching. If it matches, the server can answer 304 Not Modified.If-None-Match: "abc"
If-Modified-SinceMakes the request conditional on the resource changing after a date.If-Modified-Since: Wed, 21 Oct 2026 07:28:00 GMT
Upgrade-Insecure-RequestsTells the server the client prefers an HTTPS version of the page.Upgrade-Insecure-Requests: 1

Response headers

These headers describe the response and give the client instructions.

HeaderWhat it doesExample
Content-TypeThe media type of the body, with an optional character set.Content-Type: text/html; charset=utf-8
Content-LengthThe size of the body in bytes.Content-Length: 348
Content-EncodingThe compression applied to the body.Content-Encoding: gzip
Content-LanguageThe language of the content.Content-Language: en
Content-DispositionWhether to show the content inline or download it as an attachment, and the suggested file name.Content-Disposition: attachment; filename="report.pdf"
LocationWhere to go next. Used with 201 and with the 3xx redirect codes.Location: /new-page
ServerDescribes the software that handled the request.Server: nginx
DateWhen the response was generated.Date: Wed, 21 Oct 2026 07:28:00 GMT
Retry-AfterHow long to wait before retrying. It is either a number of seconds or a date.Retry-After: 120
AllowThe methods the resource supports, typically sent with a 405.Allow: GET, HEAD
Accept-RangesWhether the server supports range requests.Accept-Ranges: bytes
LinkRelationships to other resources, such as preloads.Link: </style.css>; rel=preload; as=style
WWW-AuthenticateTells the client how to authenticate, sent with a 401.WWW-Authenticate: Basic realm="admin"

When a response is compressed, Content-Length is the length of the encoded body, not the original file. A Content-Type without a charset can lead to wrong text decoding, so send charset=utf-8 for text types.

Caching headers

Caching headers decide whether a browser or a shared cache such as a CDN may reuse a response without asking the origin again. Caching is defined in RFC 9111. A private cache belongs to one user, like a browser cache. A shared cache serves many users, like a proxy or CDN.

Cache-Control directives

DirectiveMeaningExample
max-age=NThe response stays fresh for N seconds after it was generated on the origin.Cache-Control: max-age=604800
s-maxage=NAs max-age, but only for shared caches. It overrides max-age and Expires there.Cache-Control: s-maxage=3600
no-cacheThe response may be stored, but it must be validated with the origin before every reuse. It does not mean "do not cache".Cache-Control: no-cache
no-storeNo cache of any kind should store the response. This is the directive for "do not cache".Cache-Control: no-store
must-revalidateOnce the response is stale, it must be validated before reuse.Cache-Control: max-age=600, must-revalidate
privateOnly a private cache may store it. Use it for personalised content.Cache-Control: private
publicA shared cache may store it, even if the request used an Authorization header.Cache-Control: public, max-age=604800
immutableThe response will not change while it is fresh, so no revalidation is needed on reload.Cache-Control: max-age=31536000, immutable

Validators and related headers

A validator lets a cache ask "has this changed?" and get a short 304 answer instead of the whole body.

HeaderWhat it doesExample
ETagAn identifier for a specific version of the resource. A W/ prefix marks a weak validator.ETag: "33a64df5"
Last-ModifiedWhen the resource last changed.Last-Modified: Wed, 21 Oct 2026 07:28:00 GMT
VaryLists request headers that change the response, so caches keep separate copies. Vary: * marks the response as uncacheable.Vary: Accept-Encoding
ExpiresAn absolute date after which the response is stale. Cache-Control takes priority.Expires: Wed, 21 Oct 2026 07:28:00 GMT
AgeHow long the response has been in a shared cache, in seconds.Age: 24
If-MatchMakes a request conditional on the ETag matching. Used to avoid overwriting someone else's change.If-Match: "33a64df5"

A common pattern for a website is long caching for files with a hashed name, such as app.3f9a1c.js, and revalidation for the HTML page itself: Cache-Control: max-age=31536000, immutable for the first, and Cache-Control: no-cache with an ETag for the second.

Cookies

The server sets a cookie with Set-Cookie, and the browser returns it in the Cookie request header. The attributes below follow the name and value, separated by semicolons.

AttributeMeaningExample
SecureSend the cookie only over HTTPS.Set-Cookie: id=a3fWa; Secure
HttpOnlyHide the cookie from JavaScript. It is still sent with requests.Set-Cookie: id=a3fWa; HttpOnly
SameSite=StrictSend the cookie only for requests that start on the same site.Set-Cookie: id=a3fWa; SameSite=Strict
SameSite=LaxAlso send it on top-level navigations that use a safe method, such as clicking a link.Set-Cookie: id=a3fWa; SameSite=Lax
SameSite=NoneSend it on cross-site requests too. Secure must also be set.Set-Cookie: id=a3fWa; SameSite=None; Secure
Max-Age, ExpiresHow long the cookie lives. Without either, it is a session cookie.Set-Cookie: id=a3fWa; Max-Age=3600
Domain, PathWhich hosts and paths the cookie applies to.Set-Cookie: id=a3fWa; Path=/

Cookie names starting with __Host- must be set with Secure, must have no Domain and must use Path=/, which ties the cookie to the exact host. Some browsers treat a cookie as SameSite=Lax when the attribute is missing, so set it explicitly.

Cross-origin resource sharing (CORS)

Browsers block a page from reading a response from another origin unless that server opts in with these headers. A request that needs a permission check first triggers a preflight, an OPTIONS request carrying Access-Control-Request-Method.

HeaderWhat it doesExample
Access-Control-Allow-OriginThe origin allowed to read the response, or * for any origin on requests without credentials.Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-MethodsThe methods allowed, in a preflight response.Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-HeadersThe request headers allowed, in a preflight response.Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Allow-CredentialsAllows the page to send and read cookies and other credentials. The wildcard origin cannot be used with credentials.Access-Control-Allow-Credentials: true
Access-Control-Expose-HeadersExtra response headers that scripts may read.Access-Control-Expose-Headers: ETag
Access-Control-Max-AgeHow long the browser may cache the preflight result, in seconds.Access-Control-Max-Age: 600

If the allowed origin depends on the request, send Vary: Origin too, so a cache does not serve one origin's answer to another.

Security headers

These response headers switch on browser protections. They are cheap to add, and most security scanners look for them. CORS is not a security header in this sense: it relaxes a rule rather than adding one.

HeaderWhat it doesExample
Strict-Transport-SecurityTells the browser to use HTTPS only for this host in future. Options are max-age, includeSubDomains and preload. Browsers ignore it over plain HTTP.Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Security-PolicyRestricts where scripts, styles, images, frames and other content may load from. Key directives: default-src (the fallback), script-src, style-src, img-src, connect-src, frame-ancestors, form-action, base-uri, object-src and upgrade-insecure-requests.Content-Security-Policy: default-src 'self'; img-src 'self' data:
Content-Security-Policy-Report-OnlySame syntax, but violations are reported and not blocked. Good for testing a new policy.Content-Security-Policy-Report-Only: default-src 'self'
X-Content-Type-OptionsWith nosniff, the browser trusts the declared Content-Type and blocks scripts and styles that have the wrong type.X-Content-Type-Options: nosniff
X-Frame-OptionsControls whether the page may be shown in a frame, to prevent clickjacking. Values are DENY and SAMEORIGIN. The frame-ancestors CSP directive is the more flexible replacement. It is ignored in a meta tag.X-Frame-Options: DENY
Referrer-PolicyHow much referrer information to send. The browser default is strict-origin-when-cross-origin.Referrer-Policy: strict-origin-when-cross-origin
Permissions-PolicyAllows or denies browser features, such as the camera or geolocation, for the page and its frames.Permissions-Policy: camera=(), geolocation=()
Cross-Origin-Opener-PolicyIsolates the page's browsing context from other windows. Values: unsafe-none, same-origin-allow-popups, same-origin and noopener-allow-popups.Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-PolicyRequires embedded resources to opt in. Values: unsafe-none, require-corp and credentialless.Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Resource-PolicySays who may load this resource. Values: same-site, same-origin and cross-origin.Cross-Origin-Resource-Policy: same-origin
Clear-Site-DataAsks the browser to clear stored data, such as cookies and cache, for the site. Often sent on logout.Clear-Site-Data: "cache", "cookies"

X-XSS-Protection is deprecated and non-standard. Modern browsers do not need it when a strong Content-Security-Policy is in place. If you send it at all, the value 0 disables the old filter. A good starting set for a static site is HSTS, a restrictive CSP, nosniff, frame-ancestors or X-Frame-Options, and a Referrer-Policy. Add the cross-origin isolation headers only if you need features that depend on them, because they can break embeds.

Proxy and connection headers

These describe the path a request took, or how the connection behaves.

HeaderWhat it doesExample
ForwardedThe standard header for details of the original client and request as seen by a proxy.Forwarded: for=192.0.2.60;proto=https
X-Forwarded-ForThe older, widely used form: the client address followed by each proxy. A client can fake it, so do not trust it without a trusted proxy.X-Forwarded-For: 203.0.113.5, 198.51.100.7
ViaLists the proxies the message passed through.Via: 1.1 proxy.example.com
ConnectionOptions for the current connection, for example keep-alive or close.Connection: keep-alive
Alt-SvcAdvertises that the site is available over another protocol or host, such as HTTP/3.Alt-Svc: h3=":443"
Timing-Allow-OriginLets other origins read detailed resource timing.Timing-Allow-Origin: *

Common mistakes

Authentication tokens often travel in the Authorization header, for example as a bearer token. See JWT explained for what is inside one.

Sources