1. Home
  2. Guides
  3. HTTP headers explained
Security guide

HTTP headers explained: what your server tells browsers

Every web page comes with a short set of instructions called HTTP headers. They are invisible to visitors but decide how long a file is cached, whether it is compressed, how cookies behave, and whether search engines may index it.

Key points

  • Headers are metadata sent with every response. The browser and crawlers obey many of them.
  • The ones to know: Cache-Control, Content-Type, Content-Encoding, Location, Set-Cookie, X-Robots-Tag and the security family.
  • View them with curl, browser DevTools or a header checker, and watch for version leaks such as Server and X-Powered-By.

What headers are

A request for a page and the reply both have two parts: headers, then a body. The reply's status line and headers look like this:

HTTP/2 200
content-type: text/html; charset=utf-8
content-encoding: br
cache-control: public, max-age=3600
strict-transport-security: max-age=31536000
x-robots-tag: noindex

Header names are not case sensitive. Your web server, CDN or application adds them, and any of these can change what you see.

The groups that matter

Caching

  • Cache-Control says how long browsers and CDNs may reuse a file, for example max-age=31536000, immutable for versioned assets or no-store for private pages.
  • ETag and Last-Modified let a browser ask "has this changed?" and receive a tiny "304 Not Modified" instead of the full file.
  • Vary tells caches which request headers change the response, such as Accept-Encoding.

More in compression and caching.

Content

  • Content-Type names the format and character set. A wrong type or missing charset can cause broken text or blocked scripts.
  • Content-Encoding shows the compression used, such as br (Brotli) or gzip.
  • Content-Length gives the body size in bytes, where known.

Redirects and status

  • The status code (200, 301, 404, 503) is the first line, not a header, but it is read with the headers.
  • Location gives the target of a redirect. See 301 vs 302.
  • Retry-After tells clients when to try again after a 503 or 429.

Search engines

  • X-Robots-Tag carries the same instructions as the robots meta tag (such as noindex) and also works for PDFs and images. A leftover noindex here is a common reason a page will not appear in search, and it is easy to miss because nothing shows in the HTML.
  • Link can carry canonical and hreflang information for non-HTML files.

Cookies

  • Set-Cookie should carry Secure (https only), HttpOnly (not readable by scripts) and a SameSite value for sign-in or session cookies.

Security

  • Strict-Transport-Security, Content-Security-Policy, X-Content-Type-Options, Referrer-Policy and Permissions-Policy harden the page in the browser. They have their own guide: security headers explained.

Information leaks

  • Server and X-Powered-By often reveal software and exact versions. They do not break anything, but attackers use them to pick targets. Remove version numbers where you can.

How to view headers

  1. Online: paste an address into the HTTP header checker. It shows the status, redirect chain, every header with a plain-English note, and timing.
  2. Command line: curl -sI https://example.com/ prints the response headers. Some servers answer a HEAD request differently from a normal GET, so for a closer match use curl -s -D - -o /dev/null https://example.com/.
  3. Browser: open DevTools, go to the Network tab, reload, click the first request and read Response Headers.

Check the headers on the address a visitor actually ends up at. If the page redirects, the headers of the first response may be different from those of the final page.

Where to set them

It depends on your stack. Nginx uses add_header, Apache uses Header set, and hosts such as static site platforms and CDNs usually have a headers file or settings page. CMS plugins can also add some. After any change, test the live address rather than trusting the configuration.

# nginx
add_header X-Content-Type-Options "nosniff" always;
server_tokens off;

# Apache
Header always set X-Content-Type-Options "nosniff"
ServerTokens Prod

FAQ

What is the difference between request and response headers?

Request headers are sent by the browser, such as the language it prefers and cookies. Response headers are sent by the server, and they are the ones a header checker shows.

Can headers affect SEO?

Yes. The status code, redirects, X-Robots-Tag, canonical Link headers and caching all influence how crawlers treat a page, and server errors reduce crawling.

Why do I see headers I never set?

Your host, CDN or framework adds many by default, for example caching, compression and security headers. This is normal. Check the live response to see the final result.

Is it bad to show the Server header?

The header name alone is harmless, but exact version numbers help attackers find known flaws. Hide the version, or the header entirely, if your server allows it.

Why are headers different when I use curl?

curl sends different request headers from a browser, so some servers, CDNs or bot protections answer differently. Compare using the same address and method.

WebsiteHealthLabs Editorial
Guides explain audit results in plain English. Facts are checked against public documentation from Google, W3C and the browser vendors, and we update them when guidance changes.

↑ ↓ to moveEnter to openEsc to closeAll results