HTTP Headers Cheatsheet 2026

Updated April 2026

Quick Answer The most important HTTP security headers: Strict-Transport-Security (force HTTPS), Content-Security-Policy (prevent XSS), X-Frame-Options: SAMEORIGIN (prevent clickjacking), X-Content-Type-Options: nosniff (prevent MIME sniffing), Referrer-Policy (control referrer). Cache headers: Cache-Control, ETag, Vary.

The most important HTTP response headers in one place — security headers, cache headers, and CORS headers with exact values and stack-specific config.

Security headers — add to every site

HeaderValueWhat it does
Strict-Transport-Securitymax-age=31536000; includeSubDomainsForces HTTPS for 1 year. Prevents downgrade attacks.
Content-Security-Policydefault-src 'self';Controls which resources can load. Prevents XSS.
X-Frame-OptionsSAMEORIGINPrevents clickjacking via iframes.
X-Content-Type-OptionsnosniffPrevents MIME type sniffing.
Referrer-Policystrict-origin-when-cross-originControls what URL is sent as referrer.
Permissions-Policycamera=(), microphone=(), geolocation=()Disables unused browser APIs.
Cross-Origin-Opener-Policysame-originIsolates browsing context. Enables SharedArrayBuffer.

Cache headers

Use caseHeader value
Static assets (hashed filenames)Cache-Control: public, max-age=31536000, immutable
HTML pagesCache-Control: no-cache
Authenticated APICache-Control: no-store
Public API with SWRCache-Control: public, max-age=60, stale-while-revalidate=300
User-specific (browser cache ok, CDN not)Cache-Control: private, max-age=300

CORS headers

HeaderExample valueRequired for
Access-Control-Allow-Originhttps://app.example.comAll cross-origin responses
Access-Control-Allow-MethodsGET, POST, PUT, DELETE, OPTIONSPreflight responses
Access-Control-Allow-HeadersContent-Type, AuthorizationPreflight responses
Access-Control-Allow-CredentialstrueCookie/auth cross-origin requests
Access-Control-Max-Age86400Cache preflight for 24h
VaryOriginDynamic CORS — prevents CDN serving wrong cached response

Other useful headers

HeaderExamplePurpose
ETagW/"abc123"Cache validation — allows 304 Not Modified responses
Last-ModifiedSat, 04 Apr 2026 00:00:00 GMTCache validation fallback
Content-EncodingbrIndicates Brotli/gzip compression
VaryAccept-EncodingCDN caches separate copies per encoding
X-Content-Type-OptionsnosniffMIME sniffing protection
Server(remove or minimize)Hides server software version

Nginx — all security headers in one block

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
server_tokens off;
Scan your live headers → HeadersFixer Generate all headers → Security Headers Generator