HTTP Security Headers Guide
HTTP security headers are a critical part of securing your web application. They allow the server to instruct the web browser on how to behave, preventing a wide range of vulnerabilities, including Cross-Site Scripting (XSS), clickjacking, and data injection attacks.
Below is a complete guide to the essential security headers you should configure on your website.
Content-Security-Policy (CSP)
The most powerful security header. CSP prevents XSS and data injection by restricting where resources (scripts, styles, images) can be loaded from and executed.
Read moreHTTP Strict Transport Security (HSTS)
HSTS forces browsers to communicate with your server over HTTPS only, preventing SSL stripping and downgrade attacks.
Read moreX-Frame-Options
Prevents clickjacking attacks by ensuring your content cannot be embedded into iframes on malicious third-party sites.
Read moreX-Content-Type-Options
Stops browsers from attempting to MIME-sniff the content type, forcing them to stick with the declared Content-Type.
Referrer-Policy
Controls how much referrer information (the URL the user came from) is included with requests made to external sites.
Read morePermissions-Policy
Allows you to enable or disable specific browser features (like the camera, microphone, or geolocation) in its own frame and iframes.
Read moreCross-Origin-Embedder-Policy (COEP)
Prevents a document from loading cross-origin resources without explicit CORP authorization, stopping Spectre side-channel attacks.
Read moreCross-Origin-Opener-Policy (COOP)
Isolates top-level browsing contexts from cross-origin windows, neutralizing window.opener and tabnabbing exploits.
Read moreCross-Origin-Resource-Policy (CORP)
Instructs browsers to block unauthorized cross-origin embedding of your static images, scripts, audio, and private APIs.
Read moreCache-Control
Controls how and when responses are cached by the browser and intermediaries. Crucial for protecting sensitive data from being cached on shared systems.
Read moreClear-Site-Data
Wipes browsing data (cookies, storage, cache) tied to the requesting website. Use with caution, usually on logout endpoints.
Read moreSupports-Loading-Mode
An emerging header that indicates support for fenced frames, which provide a strict privacy boundary around embedded content.
Read moreSpeculation-Rules
Delivers speculation rules to the browser to improve performance (e.g., prefetching/prerendering) securely via HTTP headers.
Read more