Skip to content

Security · Beginner · 2 min read

Security headers, explained.

HSTS, X-Content-Type-Options, Referrer-Policy, frame protection and Permissions-Policy: what each response header does and how to set it.

HTTP response headers are instructions a server sends with a response. Security headers can require HTTPS on later visits, check script and stylesheet types, limit referrer information, and restrict which pages can frame your site. Their effect depends on the values you send and the browser applying them.

Strict-Transport-Security (HSTS)

After receiving HSTS over HTTPS, a browser remembers the policy for the max-age you specify and upgrades later HTTP visits automatically. This response header does not protect a first HTTP visit before the browser knows the policy; an inherited or preloaded HSTS policy can cover that case.

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

X-Content-Type-Options

For script and stylesheet requests, nosniff tells the browser to check the declared Content-Type and block unsuitable MIME types. It is one response-header safeguard, not a substitute for validating uploaded files or serving them safely.

Example
X-Content-Type-Options: nosniff

Referrer-Policy

The Referer header tells the destination which page a visitor came from, including any path or query string. A sensible policy sends the origin cross-site but never the full URL, so private paths and tokens don't leak.

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

Frame protection

Clickjacking works by loading your site inside an invisible frame on an attacker's page and tricking users into clicking. Deny framing with a Content-Security-Policy frame-ancestors directive (the modern approach), keeping X-Frame-Options as a fallback for older browsers.

Example
Content-Security-Policy: frame-ancestors 'none'
X-Frame-Options: DENY

Permissions-Policy

Permissions-Policy lets you switch off powerful browser features your site doesn't use (camera, microphone, geolocation) so a compromised script or embedded frame can't quietly request them.

Example
Permissions-Policy: geolocation=(), microphone=(), camera=()

How to fix it

Set these on the server or edge, not per page. On Cloudflare you can add them with a Transform Rule or in a Worker; on nginx use add_header; on Apache use Header set. Add one at a time, deploy, and re-scan to confirm each is present and well-formed.

Glossary

Header
A name/value line the server sends with a response, carrying metadata the browser acts on before rendering.
max-age
How long (in seconds) the browser should remember a directive such as HSTS.
Clickjacking
Tricking a user into clicking something different from what they perceive, usually via a hidden frame.

See where your site stands.

A free scan checks one public page for the security headers, accessibility and search basics Zenith covers. Not every topic here is part of that check.