DELAPARRA
Index
Color
NL

HTTP headers review

Use when reviewing or setting HTTP response headers for a web app or API - security headers (Content-Security-Policy, Strict-Transport-Security, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy), CORS headers, caching headers (Cache-Control, ETag, Last-Modified, Vary) and cookies (Set-Cookie flags). Also use when a security scan reports missing headers.

Licence MIT

Source delaparra-original

Download zip

HTTP headers review

Inspect the headers an app actually sends, compare them to a safe baseline, and propose minimal changes in the right layer (web server, framework middleware, or CDN).

Step 1: Inspect

curl -sI https://example.com/            # HTML page
curl -sI https://example.com/api/health  # API
curl -sI https://example.com/build/app.js # static asset

Check each type of response separately: pages, API responses and static assets need different caching.

Step 2: Security baseline (HTML responses)

Header Recommended starting value Notes
Strict-Transport-Security max-age=31536000; includeSubDomains Only on HTTPS. Add preload only when every subdomain is HTTPS
Content-Security-Policy Start with Content-Security-Policy-Report-Only and a tight policy, e.g. default-src 'self'; img-src 'self' data:; object-src 'none'; base-uri 'self'; frame-ancestors 'self' Switch to enforcing after reports are clean. Avoid 'unsafe-inline' for scripts; use nonces (Vite/Laravel support nonces)
X-Content-Type-Options nosniff Always
X-Frame-Options SAMEORIGIN (or CSP frame-ancestors) Prevents clickjacking
Referrer-Policy strict-origin-when-cross-origin
Permissions-Policy e.g. camera=(), microphone=(), geolocation=() Disable what the app does not use

Remove headers that leak versions: X-Powered-By, detailed Server values (expose_php = Off in php.ini, server_tokens off; in Nginx).

Step 3: Cookies

Set-Cookie for sessions must have Secure, HttpOnly and SameSite=Lax (or Strict). In Laravel: SESSION_SECURE_COOKIE=true, config/session.php same_site. Use SameSite=None; Secure only when a cross-site cookie is truly required.

Step 4: CORS (APIs)

  • Access-Control-Allow-Origin: list exact origins. * is only acceptable for fully public, credential-less APIs.
  • With cookies/credentials: Access-Control-Allow-Credentials: true and a specific origin, plus Vary: Origin.
  • Access-Control-Allow-Methods / -Headers: only what is used. Access-Control-Max-Age reduces preflight requests.

Step 5: Caching

Response Cache-Control
Fingerprinted assets (app.3f9a.js) public, max-age=31536000, immutable
HTML pages no-cache (revalidate) or a short max-age; use ETag/Last-Modified
Authenticated/personal API data private, no-store
Public API data public, max-age=60 plus ETag

Add Vary for any header that changes the response (Accept-Encoding, Origin, Accept-Language).

Step 6: Apply in one place

Pick one layer per header (Nginx/Apache config, a Laravel middleware, or the CDN) to avoid duplicates. Verify with curl -sI again and report a before/after table.

Rules

  • Never enforce a new CSP without a report-only phase on an existing site.
  • Never enable HSTS preload without explicit confirmation from the owner.

Files

  • LICENSE
  • SKILL.md
  • SOURCE.md

Related terms

Installing an agent skill in Claude Code, Codex, Cursor and Copilot