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.

SecurityEssential (A+)

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';
NGINX, Apache, Next.js configs & directives
SecurityEssential (A+)

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; preload
NGINX, Apache, Next.js configs & directives
SecurityEssential (A+)

X-Frame-Options

Indicates whether a browser should be allowed to render a page inside an <iframe>, <frame>, or <object>, protecting users against clickjacking attacks.

SecurityEssential (A+)

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.

SecurityHighly Recommended

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-origin
NGINX, Apache, Next.js configs & directives
SecurityHighly Recommended

Permissions-Policy

Allows site owners to selectively restrict browser hardware features, sensors, APIs, and privacy-invasive tracking mechanisms.

camera=(), microphone=(), geolocation=(), browsing-topics=()
NGINX, Apache, Next.js configs & directives
CachingEssential (A+)

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)
NGINX, Apache, Next.js configs & directives
CORSContext-Dependent

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)
NGINX, Apache, Next.js configs & directives
AuthenticationEssential (A+)

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>
NGINX, Apache, Next.js configs & directives
Transport & CookieEssential (A+)

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=/
NGINX, Apache, Next.js configs & directives
SecurityHighly Recommended

Cross-Origin-Opener-Policy (COOP)

Isolates your top-level browsing context from other origins, preventing cross-origin window tampering and Spectre side-channel attacks.

CachingContext-Dependent

ETag (Entity Tag)

Unique hash or identifier for a specific version of a resource, allowing efficient cache revalidation with 304 Not Modified responses.

W/"33a64df551425fcc55e4d42a148795d9f25f89d4"
NGINX, Apache, Next.js configs & directives