Contents

Website security headers are HTTP response headers that tell a browser to apply extra protections when loading a page. They work alongside secure code rather than replacing it. For example, headers can tell the browser to use HTTPS only, block content loaded from untrusted sources, or prevent the page from being embedded inside another site.
This guide walks through common security headers, including HSTS, Content-Security-Policy, X-Content-Type-Options, Referrer-Policy, X-Frame-Options and Permissions-Policy. It covers what to provide when checking headers, what results typically look like, safe starting configurations, common mistakes, and a step-by-step workflow for moving from inspection to configuration.
Nothing here claims a particular scanning capability for any third-party tool. Readers should verify feature availability directly on the tool or service they plan to use before relying on it.
Illustration: a conceptual diagram of a browser receiving HTTP response headers from a server and applying protections such as HSTS, Content-Security-Policy, and framing controls.
What security headers are and why they matter
Security headers are HTTP response headers sent by a web server to a browser. They instruct the browser to enforce additional protections for the site. These headers add a defensive layer but do not replace secure coding, input validation, or proper access controls.
Their scope is limited to the browser’s behavior while visiting the site. A header cannot fix a vulnerable backend, stop all attacks, or protect users once they leave the domain. Because headers are delivered with responses, they only affect pages that actually load and receive them.
Beginners should think of security headers as configuration-level settings. Many require only one line of server configuration, though more complex headers such as Content-Security-Policy take more planning. Even simple headers can meaningfully reduce the risk of common issues such as protocol downgrade attacks, clickjacking, and certain reflected injection problems.
Headers do not guarantee security by themselves. A missing header indicates an available protection is not being advertised to the browser, while a present header does not prove the site is secure. Both presence and absence should be interpreted as signals worth verifying, not as final conclusions.
Input, outputs and decisions for a security-header check
What a user typically provides
A header check usually starts with a target URL or domain. The user may need to specify whether to test the homepage, login pages, checkout pages, or other representative paths. Different paths can return different headers, so checking only one page may miss issues elsewhere on the site.
Users may also choose whether to test over HTTPS, HTTP, or both. Some headers behave differently or are intentionally not sent over plain HTTP. The user may need to decide whether to include subdomains, especially before considering HSTS with subdomain coverage.
What results typically look like
A header inspection result generally lists the response headers returned for the requested URL. It may show which security headers are present, which are missing, and sometimes the values assigned to each header. A result might also classify headers as present or absent, but the exact format depends on the tool.
A report-only header, such as Content-Security-Policy-Report-Only, may appear alongside an enforced header. Report-only headers tell the browser to send violation reports without blocking resources, which can look similar to enforcement in a simple list.
What conclusions can safely be drawn
A reader can safely conclude which headers the server sent for that specific URL and request. They can compare observed headers against intended policy and identify obvious gaps.
Readers should not conclude that a site is secure because a header is present, nor that it is insecure solely because a header is missing. Header presence is configuration evidence, not proof of protection effectiveness. Results from one URL should not be generalized to the entire site without testing additional paths.
Decisions based on a check might include adding a missing header, adjusting a value, testing in report-only mode first, or scheduling a review after third-party changes.
Recommended adoption order for security headers
Start with HTTPS readiness
Before enabling HSTS, confirm the site is reachable over HTTPS and that HTTPS works reliably across the pages and subdomains you intend to protect. Enabling HSTS too early can lock visitors out if HTTPS is not fully ready.
Early adoption headers
Headers with low implementation effort and clear benefits are good starting points. These commonly include:
- X-Content-Type-Options: nosniff
- X-Frame-Options: DENY or SAMEORIGIN
- Referrer-Policy: no-referrer or strict-origin-when-cross-origin
- Permissions-Policy: a restrictive baseline appropriate to the site’s features
These headers generally require one line of configuration and address specific browser behaviors.
HSTS
HTTP Strict Transport Security tells the browser to use HTTPS for a domain for a set period, even if the user types http:// or follows an old link. This helps prevent protocol downgrade and cookie hijacking on the first insecure request.
A sample HSTS header is:
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Beginners should start with a short max-age and expand it only after HTTPS is stable. includeSubDomains should be added only after confirming every subdomain supports HTTPS. The preload directive should be used only with careful consideration, because removal can be slow.
Content-Security-Policy
Content-Security-Policy tells the browser which sources of scripts, styles, frames, and other resources are allowed. This mitigates cross-site scripting by blocking injected scripts that do not match the policy.
CSP takes more effort than most headers because it must account for inline scripts, external scripts, styles, images, frames, and third-party services. It should generally begin in report-only mode so violations can be observed before enforcement blocks legitimate resources.
Suggested order
- Confirm HTTPS is working.
- Add simple headers: X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy.
- Add HSTS with a short max-age, then increase gradually.
- Build CSP in report-only mode, review reports, then enforce.
- Recheck after theme, plugin, or third-party changes.
Header-by-header practical guidance
HSTS
Strict-Transport-Security instructs the browser to use HTTPS for a specified period. Accepted components include max-age, includeSubDomains, and preload. A safe starting configuration uses a short max-age without includeSubDomains until HTTPS is confirmed across all subdomains. Long max-age values before HTTPS is ready can cause access problems.
Content-Security-Policy
CSP controls allowed sources for scripts, styles, frames, images, and other resources. Values are expressed as directives such as default-src, script-src, style-src, and frame-ancestors. A strict policy may require nonces or hashes for inline scripts. Begin with Content-Security-Policy-Report-Only and a reporting endpoint. Reports are sent to the endpoint named in the report-to directive, defined with Reporting-Endpoints; many teams also include report-uri for older browser support.
X-Content-Type-Options
The value nosniff tells the browser not to MIME-sniff responses away from the declared content type. This is typically a single-value header with little configuration complexity.
X-Frame-Options
Accepted values commonly include DENY and SAMEORIGIN. DENY prevents the page from being framed by any site. SAMEORIGIN allows framing only by the same origin. Choose based on whether the page is ever intentionally embedded in another page on your own site.
Referrer-Policy
This header controls how much referrer information is sent when users navigate away. Common values include no-referrer, strict-origin-when-cross-origin, and no-referrer-when-downgrade. The right choice depends on whether the site needs to share referral data with external destinations.
Permissions-Policy
Permissions-Policy controls browser features such as camera, microphone, geolocation, and fullscreen. Values use feature and allowlist syntax. Start with a restrictive baseline and enable only features the site actually uses.
X-XSS-Protection
This older header was designed to enable cross-site scripting filters in some browsers. Modern guidance generally favors CSP instead. Do not rely on X-XSS-Protection as a primary protection.
Known cautions
Header syntax must match the server’s expected format. A typo can prevent the header from being sent or cause it to be ignored. Headers set at the origin server may not match headers delivered by a CDN or proxy. Test the public URL, not only the origin.
CSP is especially easy to break accidentally. Inline scripts, inline styles, eval(), and third-party embeds may all require explicit allowances, nonces, or hashes. Enforcing CSP too early can break legitimate site functionality.
Common mistakes and verification steps
Applying headers over plain HTTP
Some security headers are intended for HTTPS contexts. HSTS, for example, is generally ignored over plain HTTP. Do not assume HTTPS-only protections apply simply because the header is present in an HTTP response.
Long HSTS max-age before HTTPS is ready
Setting a long max-age before HTTPS is stable can keep browsers attempting HTTPS even after a misconfiguration, potentially blocking access. Start short and extend only after confirming stability.
Relying on X-XSS-Protection
X-XSS-Protection is outdated and limited. It should not be treated as a substitute for CSP, output encoding, or input validation.
Treating a present header as proof of security
A header tells the browser what to do; it does not prove the site is free of vulnerabilities. Misconfigured values, missing subdomains, or inconsistent CDN behavior can leave gaps even when headers appear present.
Inconsistent headers across origin and CDN
Headers set on the origin server may not reach visitors unchanged if a CDN or proxy rewrites responses. Verify headers at the public URL users actually visit.
Verification steps
Check headers directly in browser developer tools under the Network tab. Reload the page and inspect the response headers for the document request. Compare multiple URLs, including login and payment-related pages if applicable. Test over both HTTP and HTTPS only if you understand the intended behavior, and remember that HTTP results may not reflect HTTPS protections.
After configuration changes, reload and re-inspect. Check report-only endpoints if using CSP reporting to see whether legitimate resources are being flagged.
Workflow from check to configuration decision
Step 1: Choose URLs to check
Include the homepage and representative paths such as login, account, and checkout pages. Different paths may use different server configurations or templates.
Step 2: Inspect headers in developer tools
Open developer tools, select the Network tab, reload the page, and click the main document request. Review the response headers. Note which security headers are present, which are missing, and whether any are report-only rather than enforced.
Step 3: Compare against a sample header block
Create a reference block with the headers you intend to use. For example:
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Content-Security-Policy: default-src ‘self’
Compare observed headers against this reference. Differences may indicate missing configuration or intentional deviations.
Step 4: Test CSP in report-only mode
Before enforcing CSP, use Content-Security-Policy-Report-Only with a reporting endpoint. Review violation reports to identify inline scripts, third-party scripts, or embeds that require nonces, hashes, or exceptions.
Step 5: Make configuration decisions
Decide whether to add missing headers, adjust values, narrow or broaden allowlists, or delay enforcement until reports are clear. Prioritize HTTPS readiness before HSTS and subdomain inclusion.
Step 6: Review after third-party changes
Adding or removing a third-party script, embed, analytics tag, or widget can change which resources a page loads. After such changes, re-inspect headers and CSP reports. A new script may be blocked by CSP or may require a policy update.
Step 7: Schedule regular review
Security-header policy should be reviewed periodically and after major site changes, CMS updates, CDN changes, or new integrations. There is no universal interval from this guide; choose a cadence that fits your release and change management process.