· 5 min read
What Do Those HTTP Security Headers Actually Do?
Manesh Jayawardhana
CIO & Co-founder
You’ve opened your browser’s dev tools, clicked the Network tab, and there they are: Strict-Transport-Security, X-Content-Type-Options, Content-Security-Policy, a dozen response headers with cryptic values. Someone told you your site “needs security headers,” a scanner flagged three of them as missing, and now you’re staring at a wall of header names trying to figure out which ones actually matter for your situation and which are boilerplate.
The frustrating part is that most explanations of security headers assume you already know what a directive like nosniff or max-age=31536000; includeSubDomains means. You end up copy-pasting a header value from a blog post without understanding what it actually restricts — which works until it silently breaks something, like a third-party embed that a Content-Security-Policy header you copied from someone else’s site now blocks.
What security headers actually do
HTTP response headers are instructions your server sends alongside every page that tell the browser how to behave — what origins can embed this page in an iframe, whether to guess a file’s MIME type or trust what the server declared, whether to force HTTPS on every future visit, what scripts and resources are allowed to load. They’re a browser-enforced contract: the server states a policy, and the browser applies it regardless of what the page’s JavaScript tries to do otherwise. That’s what makes them meaningfully different from client-side security measures — a malicious script running on the page can’t override a header the browser already applied.
Each header addresses a different, specific risk. X-Frame-Options or frame-ancestors in a CSP prevents your page from being embedded in someone else’s iframe for clickjacking. Strict-Transport-Security tells the browser to never load your site over plain HTTP again, closing a downgrade-attack window. Content-Security-Policy is the broadest and most powerful, controlling what scripts, styles, and resources the page is allowed to load at all.
Why people get stuck here
- Headers interact with each other. A strict CSP without the right
unsafe-inlineor nonce handling can break inline scripts your site actually needs, and the failure mode is a silently broken page, not a helpful error message. - Scanner tools grade presence, not correctness. A scanner might mark
Content-Security-Policyas present even if its value is so permissive it provides almost no protection. - Copy-pasted values don’t fit every site. A CSP or
Permissions-Policyvalue copied from a tutorial assumes that tutorial’s exact set of third-party scripts and embeds — yours is different. - The consequences of getting a header wrong aren’t visible immediately. A missing
X-Content-Type-Options: nosniffdoesn’t break anything visibly; it just quietly removes a layer of protection against MIME-sniffing attacks.
What a good headers explainer looks like
Explains each header in plain language, not just the spec definition
You should be able to paste your actual response headers and get back what each one is doing for your specific site, not a generic definition copied from the spec.
Flags what’s commonly recommended but missing
Beyond explaining what’s present, a useful tool tells you what’s conspicuously absent compared to common baseline recommendations, so you know what to look into next.
Doesn’t require sending your headers to a third-party scanning service
Response headers can reveal details about your infrastructure. A tool that explains headers you paste in, entirely in your browser, doesn’t add a new place where that information gets logged.
| Header | Protects Against | Common Mistake |
|---|---|---|
| Strict-Transport-Security | HTTP downgrade attacks | Forgetting includeSubDomains when subdomains also need HTTPS |
| Content-Security-Policy | XSS, unauthorized resource loading | Copying an overly permissive policy that provides little protection |
| X-Content-Type-Options | MIME-sniffing attacks | Leaving it out entirely, assuming it’s optional |
| X-Frame-Options / frame-ancestors | Clickjacking via iframe embedding | Setting it too loosely, allowing broader embedding than intended |
Common mistakes to avoid
- Copying a Content-Security-Policy from another site without auditing what scripts and embeds your own site actually needs.
- Treating a scanner’s green checkmark as proof a header is correctly configured, rather than just present.
- Adding
Strict-Transport-Securitywithout testing on a staging domain first — a misconfiguredmax-agecan lock out HTTP access longer than intended. - Ignoring headers because “the site works fine without them” — most of what they protect against isn’t visible until it’s exploited.
- Setting
X-Frame-Options: DENYon a page that legitimately needs to be embedded elsewhere, breaking a legitimate integration.
How to check your headers with Security Headers Explainer
Online Tool Store’s Security Headers Explainer runs entirely in your browser.
- Open your browser’s dev tools on your site, go to Network, and copy the response headers from any request.
- Paste them into the tool.
- Read the plain-language explanation of each header present.
- Review the list of commonly recommended headers that are missing from your response.
Frequently asked questions
Do I need every security header to have a secure site?
No. Some are near-universal recommendations (like X-Content-Type-Options), while others depend heavily on your site’s architecture — a strict CSP is valuable but requires real configuration effort to avoid breaking things.
What’s the difference between X-Frame-Options and CSP’s frame-ancestors?
They solve the same clickjacking problem, but frame-ancestors in a Content-Security-Policy is the newer, more flexible mechanism and is gradually superseding X-Frame-Options in modern browsers.
Can a missing header actually get my site compromised?
Not directly by itself in most cases — headers are defense-in-depth, reducing the blast radius or feasibility of an attack rather than being the sole barrier. But missing several at once meaningfully weakens your overall posture.
Final thought
Security headers are a browser-enforced policy layer, not decoration — understand what each one you set is actually restricting before copying a value from somewhere else, or you risk either a false sense of security or a silently broken page.