HTTP headers cheat sheet

This cheat sheet brings together the common HTTP headers in requests and responses: caching, cookies, security headers, and CORS. Each header comes with a short explanation and an example value, and you can search for a header, filter by topic, and copy it with one click.

Request headers

  • Host: www.example.com

    The name of the site the request is for. A server that hosts several sites on one IP address uses it to choose which site to serve. In HTTP/1.1 the client must send it with every request, and in HTTP/2 and HTTP/3 the :authority field takes its place.

  • User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)

    Identifies the browser or software that sent the request. Sites use it for statistics and to detect bots, but the client sets the value itself, so don't rely on it for security.

    Example: User-Agent: curl/8.5.0

  • Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

    The content types the client is willing to accept. The q parameter sets a weight between 0 and 1, the default is 1, and a value of 0 marks a type that isn't acceptable. APIs check this header to decide whether to return JSON.

    Example: Accept: application/json

  • Accept-Encoding: gzip, deflate, br, zstd

    The compression methods the client supports. The server picks one of them and names it in the Content-Encoding header of the response. br is Brotli compression, and zstd is Zstandard compression.

  • Accept-Language: he-IL,he;q=0.9,en-US;q=0.8,en;q=0.7

    The visitor's preferred languages from the browser settings, with a weight for each language. A multilingual site can use it to offer the right language, and it's good practice to let visitors choose another language themselves.

  • Authorization: Bearer <token>

    The client's credentials for the server. APIs commonly use a Bearer token. With the Basic scheme, the username and password are Base64-encoded, which isn't encryption, so use it only over HTTPS.

    Example: Authorization: Basic dXNlcjpwYXNz

  • Cookie: session=abc123; lang=he

    The cookies the browser has stored for the site, as name and value pairs separated by semicolons. The browser sends only the name and value, without the attributes set in Set-Cookie.

  • Referer: https://www.example.com/blog/post

    The address of the page the request came from, for example through a link or an image on the page. The header name is misspelled, and the spelling is kept for historical reasons. The Referrer-Policy header controls how much of the address is sent.

  • Origin: https://app.example.com

    The origin of the request: the scheme, the site name, and the port, without a path. Browsers send it in CORS requests and in requests other than GET or HEAD. The server checks it to decide whether to allow access from another site.

  • If-None-Match: "33a64df551425fcc"

    A conditional request with the ETag value of the stored copy. When the file hasn't changed, the server returns 304 Not Modified with no content, and the browser uses its own copy. When the request also includes If-Modified-Since, the server ignores If-Modified-Since.

  • If-Modified-Since: Wed, 21 Oct 2026 07:28:00 GMT

    A conditional request based on the date in the Last-Modified header of the stored copy. When the file hasn't changed since then, the server returns 304 Not Modified with no content.

  • Range: bytes=0-1023

    A request for only part of the file, by byte range. The server returns 206 Partial Content, or 416 when the range is outside the file. This is how an interrupted download is resumed and how a video player jumps to another point.

    Example: Range: bytes=1024-

  • X-Forwarded-For: 203.0.113.10, 198.51.100.17

    The visitor's IP address as passed on by a proxy or CDN in front of the server, and each proxy adds the address it received the request from. It's a nonstandard header that any client can forge, so rely only on addresses added by your own trusted proxies.

  • Forwarded: for=192.0.2.43;proto=https;host=www.example.com

    The standard version (RFC 7239) of X-Forwarded-For: the client address (for), the original protocol (proto), and the original site name (host). Anything along the way can change it too, so trust only values from a known proxy.

Response headers

  • Content-Type: text/html; charset=utf-8

    The content type and character encoding. The browser uses it to decide whether to display a page, run a script, or download a file. A wrong value causes garbled characters or a download instead of a display. In POST requests, it states the type of the data being sent.

    Example: Content-Type: application/json

  • Content-Length: 3495

    The size of the content in bytes. When the size isn't known in advance, HTTP/1.1 sends the content in chunks with Transfer-Encoding: chunked, without Content-Length.

  • Content-Encoding: br

    The compression method of the content, out of the methods the client listed in Accept-Encoding: gzip, br, or zstd. The browser decompresses the content before displaying it. Compressing HTML, CSS, and JavaScript files greatly cuts loading time.

    Example: Content-Encoding: gzip

  • Location: https://www.example.com/new-page

    The address a redirect response (301, 302, 303, 307, or 308) points to. In a 201 Created response, it gives the address of the newly created resource.

  • Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax

    Stores a cookie in the browser, with a separate header for each cookie. This is the recommended form for a login cookie, with all three security attributes.

  • Set-Cookie: id=a3fWa; Secure; HttpOnly

    Secure: the cookie is sent only over HTTPS. HttpOnly: scripts on the page can't read it through document.cookie, which makes it harder to steal a login cookie through an XSS vulnerability.

  • Set-Cookie: id=a3fWa; Secure; SameSite=Strict

    SameSite limits sending the cookie in requests that come from other sites. Strict: only in requests from the same site. Lax: also when a visitor follows a link from another site, in a GET request. None: also in requests from other sites, and only together with Secure. Set a value explicitly, because Chromium-based browsers treat a cookie without the attribute as Lax.

    Example: Set-Cookie: widget=1; Secure; SameSite=None

  • Set-Cookie: lang=he; Max-Age=31536000; Domain=example.com; Path=/

    Max-Age sets the lifetime in seconds and takes precedence over Expires. A cookie with neither is deleted when the browser closes. With Domain, the cookie is also sent to subdomains, and without it only to the exact host that set it. Path limits the cookie to a path on the site.

    Example: Set-Cookie: lang=he; Expires=Wed, 02 Dec 2026 06:00:00 GMT

  • Set-Cookie: __Host-session=abc123; Path=/; Secure; HttpOnly

    A cookie name prefix that the browser enforces: __Host- requires Secure, Path=/, and no Domain, so a subdomain can't overwrite the cookie. __Secure- requires only Secure.

  • Server: nginx

    The name of the web server software. The standard recommends not listing versions and components in it, because such details make it easier for attackers to find known vulnerabilities.

  • X-Powered-By: Express

    A nonstandard header that some languages and platforms add, showing the technology and the version that run the site. Turn it off in the settings, for the same reason as too much detail in the Server header.

  • Date: Sun, 15 Nov 2026 08:12:31 GMT

    The date and time the response was generated, always in GMT. Caches use it to calculate the age of the response.

  • Retry-After: 120

    How long to wait before trying again, in seconds or as a date. Sent with 503 during maintenance and with 429 Too Many Requests, when the client has sent too many requests.

    Example: Retry-After: Wed, 02 Dec 2026 06:00:00 GMT

  • WWW-Authenticate: Basic realm="Admin area"

    The authentication scheme the server requires. A 401 response must include it, and with the Basic scheme the browser shows a prompt for a username and password.

  • Vary: Accept-Encoding

    Which request headers affect the response. Caches and CDNs store a separate copy for each of their values, for example a compressed version and an uncompressed version. Vary: Cookie greatly reduces cache use, and the value * means the response varies without limit.

    Example: Vary: Accept-Encoding, Accept-Language

  • Content-Disposition: attachment; filename="report.pdf"

    attachment tells the browser to download the file under the given name, and inline tells it to display the file in the browser when possible.

    Example: Content-Disposition: inline

  • Accept-Ranges: bytes

    The server announces that it supports Range requests, meaning downloading part of a file and resuming an interrupted download. The value none means there's no support.

  • Allow: GET, HEAD, POST

    The methods the URL supports. The server must send it in a 405 Method Not Allowed response.

Caching

  • Cache-Control: max-age=3600

    The response counts as fresh for the given number of seconds, and during that time the browser and caches use the stored copy without contacting the server. When the header includes max-age, the Expires header is ignored.

  • Cache-Control: max-age=60, s-maxage=86400

    s-maxage applies only to shared caches, such as a CDN or a reverse proxy, and there it takes precedence over max-age and Expires. This way the browser checks for updates often, and the CDN keeps the page longer.

  • Cache-Control: no-cache

    The response may be stored, but before each use of the stored copy, the cache must check with the server that it's still fresh, for example with an ETag. It doesn't mean "don't cache".

  • Cache-Control: no-store

    Forbids storing the response in any cache. Suited to pages with personal information, such as a client area, a shopping cart, or a checkout page.

  • Cache-Control: private, max-age=600

    private: only the visitor's browser may store the response, not a CDN or another shared cache. Suited to content personalized for a logged-in user.

  • Cache-Control: public, max-age=86400

    public: shared caches may also store the response, even when it was sent for a request with Authorization, which usually isn't stored.

  • Cache-Control: max-age=0, must-revalidate

    must-revalidate: once the copy is stale, it can't be used before a successful check with the server. When the server is unavailable, the cache returns an error instead of a stale copy.

  • Cache-Control: public, max-age=31536000, immutable

    immutable (RFC 8246) states that the file won't change while it's fresh, so the browser doesn't recheck it even when the page is reloaded. Suited to files whose name changes with every update, such as app.3f2a1c.css.

  • Cache-Control: max-age=600, stale-while-revalidate=60

    stale-while-revalidate (RFC 5861) allows serving an expired copy for the given number of seconds while checking with the server in the background for a new version. Works in browsers and CDN services that support the directive.

  • ETag: "33a64df551425fcc"

    An identifier of the current version of the file, which changes when the content changes. The browser sends it in the If-None-Match header, and when nothing has changed it gets 304 with no content. The W/ prefix marks a weak identifier, which indicates equivalent content rather than content identical byte for byte.

    Example: ETag: W/"0815"

  • Last-Modified: Wed, 21 Oct 2026 07:28:00 GMT

    The time the file was last changed. The browser sends it in the If-Modified-Since header to check whether there's a new version. ETag is more precise, because Last-Modified is accurate only to the second.

  • Expires: Tue, 01 Dec 2026 16:00:00 GMT

    The time after which the response is stale. A legacy header: when max-age is present, Expires is ignored. An invalid value, such as 0, counts as a time that has already passed.

  • Age: 3600

    How many seconds have passed since the response was generated or checked with the server. A shared cache or CDN adds it, so it usually indicates that the response was served from a cache.

Security headers

  • Strict-Transport-Security: max-age=31536000; includeSubDomains

    HSTS tells the browser to access the site only over HTTPS for the given number of seconds, and includeSubDomains applies this to all subdomains as well. The browser ignores the header when it's sent over HTTP. The value max-age=0 cancels the setting.

  • Strict-Transport-Security: max-age=63072000; includeSubDomains; preload

    preload isn't part of the standard, and it asks for the domain to be included in the list built into browsers. Submitting the domain at hstspreload.org requires a max-age of at least one year, includeSubDomains, the preload directive, and HTTPS on every subdomain. Removal from the list takes months, so submit only when every site on the domain works over HTTPS.

  • Content-Security-Policy: default-src 'self'; img-src 'self' https:; object-src 'none'

    CSP sets which sources scripts, styles, images, and other resources may be loaded from, which limits the damage of XSS vulnerabilities. default-src applies to every type that isn't set separately, and 'self' means the site itself.

    Example: Content-Security-Policy: script-src 'self' https://cdn.example.com

  • Content-Security-Policy-Report-Only: default-src 'self'

    Test mode: the browser reports policy violations in the developer tools and blocks nothing. Test a new policy this way before you enforce it, because a wrong policy can block scripts the site needs. The report-to directive sets where the reports are sent.

  • Content-Security-Policy: frame-ancestors 'self'

    Sets which sites may display the page in an iframe, as protection against clickjacking. 'none' blocks all embedding. It replaces X-Frame-Options, and when it's set, the browser ignores X-Frame-Options. It doesn't work from a meta tag.

    Example: Content-Security-Policy: frame-ancestors 'none'

  • Content-Security-Policy: upgrade-insecure-requests

    The browser loads images, scripts, and other files that the page links to with http addresses over HTTPS. A quick fix for mixed content warnings after moving to HTTPS, as long as the files are available over HTTPS.

  • X-Content-Type-Options: nosniff

    The browser doesn't guess the file type and goes only by Content-Type. A script sent without a JavaScript type, or a stylesheet sent without text/css, is blocked.

  • X-Frame-Options: SAMEORIGIN

    The older header against clickjacking: DENY blocks any display in a frame, and SAMEORIGIN allows only pages from the same site. Today the CSP frame-ancestors directive does this job, and X-Frame-Options stays for older browsers.

    Example: X-Frame-Options: DENY

  • Referrer-Policy: strict-origin-when-cross-origin

    Sets how much of the page address is sent in the Referer header. With this value, the browser sends the full address within the same site, only the origin (the scheme and domain, without a path) to other sites, and nothing when going from HTTPS to HTTP. This is the default in current browsers. no-referrer prevents sending it at all.

    Example: Referrer-Policy: no-referrer

  • Permissions-Policy: camera=(), microphone=(), geolocation=(self)

    Sets which browser features the page and the iframes inside it may use. () turns the feature off for everyone, and (self) allows it only for the site itself. This header replaced Feature-Policy.

  • Cross-Origin-Opener-Policy: same-origin

    Separates the window from windows of other sites that opened it or that it opened, as protection against cross-window attacks. same-origin-allow-popups keeps the link to popups the page opens, for example a payment or login window.

    Example: Cross-Origin-Opener-Policy: same-origin-allow-popups

  • Cross-Origin-Embedder-Policy: require-corp

    The page loads resources from other sites only when they allow it through CORS or Cross-Origin-Resource-Policy. Together with COOP same-origin, the page becomes cross-origin isolated, which some advanced browser features, such as SharedArrayBuffer, require.

    Example: Cross-Origin-Embedder-Policy: credentialless

  • Cross-Origin-Resource-Policy: same-origin

    Sets which sites may load the file: same-origin for the same site only, same-site for the same domain and its subdomains, and cross-origin for any site.

    Example: Cross-Origin-Resource-Policy: cross-origin

CORS

  • Access-Control-Allow-Origin: https://app.example.com

    The site that may read the response from JavaScript in the browser. The value * allows any site, but it doesn't work for requests with cookies or credentials. A server that returns a different value depending on Origin adds Vary: Origin, so the cache doesn't serve one site's response to another site.

    Example: Access-Control-Allow-Origin: *

  • Access-Control-Allow-Credentials: true

    Allows reading the response even when the request was sent with cookies or credentials. The only value is true, in lowercase, and Access-Control-Allow-Origin must name an explicit site.

  • Access-Control-Allow-Methods: GET, POST, PUT, DELETE

    The methods the other site may use. Sent in response to a preflight request.

  • Access-Control-Allow-Headers: Content-Type, Authorization

    The request headers the other site may send. Sent in response to a preflight request, and needed, for example, when the request includes Content-Type: application/json or Authorization.

  • Access-Control-Max-Age: 600

    How many seconds the browser keeps the preflight response instead of sending a preflight request again for every request. Without the header, the default is 5 seconds.

  • Access-Control-Expose-Headers: ETag, X-Total-Count

    Additional response headers that JavaScript on the other site may read. Without the header, the script sees only a small set of basic headers, such as Content-Type.

  • Access-Control-Request-Method: PUT

    Preflight request: before a request other than GET, HEAD, or POST, or a request with special headers, the browser sends an OPTIONS request with Origin, the requested method, and the requested headers. The actual request is sent only if the server's response allows them.

    Example: Access-Control-Request-Headers: content-type, authorization

Deprecated headers

  • X-XSS-Protection: 0

    Nonstandard and deprecated. The filter it turned on has been removed from current browsers, and in older browsers it can even create vulnerabilities. Don't send it, or send 0, and protect against XSS with Content-Security-Policy.

  • Expect-CT: max-age=86400, enforce

    Deprecated. It was supported only in Chromium-based browsers, which deprecated it because they enforce Certificate Transparency by default. You can remove it from the server settings.

  • Pragma: no-cache

    A header from the days of HTTP/1.0 that the current standard defines as deprecated. Its meaning in a response was never defined, so use Cache-Control: no-cache or no-store instead.

  • Feature-Policy: camera 'none'

    The former name and syntax of Permissions-Policy. Rewrite the setting in the new syntax, for example Permissions-Policy: camera=().

  • Warning: 110 - "Response is Stale"

    Defined as obsolete in the current caching standard (RFC 9111), because it was hardly used. Its information can be inferred from other headers, such as Age.

How to see a site's headers

The command curl -I https://example.com shows only the status line and the response headers, and curl -IL https://example.com also shows every response in the redirect chain. More commands for checking websites are on the curl commands page. In the browser, open the developer tools (F12), go to the Network tab, reload the page, and select a request to see its request headers and response headers. In the HTTP header analyzer, paste the output and get an explanation of each header and a summary of the security headers.

Where to set headers

Most response headers are set in the web server configuration, in the .htaccess file on servers that support it, in the CDN settings, or in the site's own code. Ready-made examples of security and caching headers in .htaccess are on the .htaccess cheat sheet. After every change, check the actual response, because a header set twice, on the server and in the site, can appear in the response with two values.

Did you know?

With our web hosting plans, an SSL certificate is activated for your site with one click, at no cost, so your site loads over HTTPS and security headers such as HSTS work as they should. With VPS hosting, you connect to Linux servers over SSH with full root privileges and set the security and caching headers directly in the web server configuration.

Web hosting plans

HTTP headers FAQ

What are HTTP headers, and what do they control on a website?

HTTP headers are lines of information sent before the content in every request and every response. Visitors don't see them, but they determine how the browser handles the page: the content type and compression, how long to keep files in the cache, which cookies to store, where to redirect, and which security restrictions to apply. Setting them correctly improves both the loading speed and the security of your site.

Which security headers should I set on my website?

The common baseline is Strict-Transport-Security for HTTPS-only connections, X-Content-Type-Options: nosniff, protection against display in a frame with frame-ancestors or X-Frame-Options, Referrer-Policy, and Permissions-Policy. Set up Content-Security-Policy gradually, and test it first in Report-Only mode. The HTTP header analyzer shows which security headers your site already sends.

Why doesn't a change I made to my site show up in the browser?

Usually the browser or the CDN is serving a stored copy, according to the Cache-Control header. The Age header in the response shows how many seconds the copy has been stored. Reload the page without the cache, purge the CDN cache, and for files that change often, set a short max-age or no-cache.

How do I fix a CORS error in the browser?

A CORS error appears when JavaScript on one site calls a URL on another site, and the other site's server doesn't allow it. The fix is on the server that receives the request: add Access-Control-Allow-Origin with the address of the calling site, and for requests with special methods or headers, also answer the OPTIONS request with Access-Control-Allow-Methods and Access-Control-Allow-Headers. CORS is enforced only in the browser, so the same request from curl isn't blocked.

How do I check which headers my site sends?

The quickest way is the command curl -I https://example.com, which shows only the response headers. In the browser, open the developer tools, go to the Network tab, and select the request. You can paste the output into the HTTP header analyzer and get an explanation of each header.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement