Book a call Free rebuild
Home/Glossary/Hosting/HTTP Header

HTTP Header

February 14, 2023 Updated November 16, 2026 2 min read

Hosting glossaryAn HTTP header is a line of information sent with a web request or response, such as the content type, caching rules, or security policies.

Every HTTP request and response is made of two parts: headers and a body. The body is the content itself, such as the HTML of a page or the bytes of an image. The headers come first and describe it: what kind of content it is, how long it may be cached, whether it is compressed, which cookies go with it, and what the browser is allowed to do with it. Each header is a single line in the form Name: value, and header names are not case-sensitive.

Request headers

Sent by the browser (or a bot) with each request. Common ones:

  • Host: the domain being requested, which lets one server host many sites.
  • User-Agent: the browser or bot making the request.
  • Accept-Encoding: the compression formats the client understands, such as gzip and Brotli.
  • Cookie: cookies previously set by the site, including WordPress login cookies.
  • Referer: the page the visitor came from (the misspelling is in the original specification).

Response headers

Sent by the server with its answer:

  • Content-Type: what the body is, for example text/html; charset=UTF-8.
  • Cache-Control: whether and for how long browsers and CDNs may cache the response.
  • Content-Encoding: how the body was compressed.
  • Set-Cookie: cookies for the browser to store.
  • Location: where to go next, used with redirects.
  • X-Robots-Tag: indexing rules such as noindex, useful for PDFs and other files that cannot carry a meta robots tag.

Security headers

  • Strict-Transport-Security (HSTS): tells browsers to use HTTPS only.
  • Content-Security-Policy: limits where scripts, styles, and other resources may load from, a strong defense against cross-site scripting.
  • X-Content-Type-Options: nosniff: stops browsers guessing a file's type.
  • X-Frame-Options, or the CSP frame-ancestors directive: controls whether other sites can embed your pages in frames, which prevents clickjacking.
  • Referrer-Policy and Permissions-Policy: control what referrer data is shared and which browser features pages may use.

The older X-XSS-Protection header is obsolete; modern browsers ignore it.

How to check headers

In the browser, open developer tools, go to the Network tab, reload, and click a request. From the command line, curl -I https://example.com/ prints the response headers.

Setting headers on a WordPress site

Headers can be set in the web server configuration (Apache's .htaccess with mod_headers, or NGINX's add_header), at the CDN, by a plugin, or in PHP through the send_headers hook. Server or CDN level is usually best, because it also covers images and other static files that never pass through WordPress.

Two mistakes come up often. Caching headers that are too aggressive can serve logged-in or cart pages to the wrong visitor. And a Content Security Policy written without testing can break scripts across the site; roll it out with Content-Security-Policy-Report-Only first and switch to enforcement once the reports are clean.

Source: MDN Web Docs, HTTP headers.

HostList

The hosting directory with no paid rankings.

Compare 30,000+ web hosts and MSPs across 120+ countries, ranked by HRI, an independent 0 to 100 rating built from verified data. Find your perfect web host.