HTTP Headers & Security Directives Directory
Essential HTTP response and request headers explained. Master Content-Security-Policy, HSTS, Cache-Control, CORS, and cookie security with ready-to-copy server configs for NGINX, Apache, Next.js, and Express.
Content-Security-Policy (CSP)
Restricts where scripts, images, styles, and frames can be loaded from, protecting websites from Cross-Site Scripting (XSS) and data injection attacks.
default-src 'self'; img-src 'self' data: https:; script-src 'self'; style-src 'self' 'unsafe-inline'; object-src 'none';Strict-Transport-Security (HSTS)
Forces modern web browsers to communicate exclusively over encrypted HTTPS connections, preventing SSL stripping and man-in-the-middle (MITM) attacks.
max-age=63072000; includeSubDomains; preloadX-Frame-Options
Indicates whether a browser should be allowed to render a page inside an <iframe>, <frame>, or <object>, protecting users against clickjacking attacks.
X-Content-Type-Options
Prevents the browser from MIME-sniffing a response away from the declared Content-Type header, mitigating drive-by malware and MIME confusion attacks.
Referrer-Policy
Controls how much referrer information (URL path and query parameters) is included when navigating away or loading external assets.
strict-origin-when-cross-originPermissions-Policy
Allows site owners to selectively restrict browser hardware features, sensors, APIs, and privacy-invasive tracking mechanisms.
camera=(), microphone=(), geolocation=(), browsing-topics=()Cache-Control
Specifies browser and CDN caching directives for requests and responses, dramatically accelerating load speeds or preventing cache leakage.
public, max-age=31536000, immutable (Static Assets) OR no-store, max-age=0 (Dynamic APIs)Access-Control-Allow-Origin (CORS)
Tells browsers which specific origins are permitted to access resources via XMLHttpRequest or Fetch API across domains.
https://app.example.com (Never wildcard * with credentials)Authorization
Contains the client credentials used to authenticate a user agent with the server, most commonly holding JWT or OAuth access tokens.
Bearer <token> OR Basic <base64-credentials>Set-Cookie
Transfers session cookies from server to client with security flags controlling JavaScript access, cross-site transmission, and SSL encryption.
session_id=xyz; Secure; HttpOnly; SameSite=Lax; Path=/Cross-Origin-Opener-Policy (COOP)
Isolates your top-level browsing context from other origins, preventing cross-origin window tampering and Spectre side-channel attacks.
same-originETag (Entity Tag)
Unique hash or identifier for a specific version of a resource, allowing efficient cache revalidation with 304 Not Modified responses.
W/"33a64df551425fcc55e4d42a148795d9f25f89d4"