What is the difference between a request header and a response header?+
Request headers are sent by the client to describe the request, its content, the credentials, what response formats it accepts. Examples: Accept, Authorization, User-Agent, Origin, Cookie. Response headers are sent by the server to describe the response or instruct the client. Examples: Content-Type, Set-Cookie, Cache-Control, Strict-Transport-Security. A few headers (Content-Type, Content-Length, Cache-Control) work in both directions.
What are the most important security headers?+
Five baseline security headers every production site should set: (1) Strict-Transport-Security to enforce HTTPS, (2) Content-Security-Policy to mitigate XSS, (3) X-Content-Type-Options: nosniff to disable MIME sniffing, (4) Referrer-Policy: strict-origin-when-cross-origin to limit referrer leakage, and (5) Permissions-Policy to disable APIs the site does not use. CSP is the highest-leverage of the five, a strict CSP closes off the majority of XSS attack vectors even when other defenses fail.
How do I see HTTP headers in the browser?+
Open DevTools (F12 in Chrome, Firefox, or Edge), switch to the Network tab, and reload the page. Click any request to see the Request Headers and Response Headers panels. For HTTPS requests, you see headers in plaintext even though the wire is encrypted. From the terminal, use 'curl -i <url>' for response headers or 'curl -v <url>' for both directions including the TLS handshake.
What is the Vary header and when do I need it?+
Vary tells caches (browser cache, CDN, reverse proxy) that the response depends on the listed request headers. Without Vary: Accept-Encoding, a CDN might serve a gzipped response to a client that did not send Accept-Encoding: gzip. The most common gotcha is CORS: if you echo Access-Control-Allow-Origin based on the request's Origin header, you must add 'Origin' to Vary or the CDN will serve a cached response with the wrong origin.
What is the difference between Cache-Control and Expires?+
Both control caching. Cache-Control is the modern HTTP/1.1 directive with rich semantics (max-age, no-store, public/private, immutable). Expires is the HTTP/1.0 header that gives a hard absolute date. When both are present, Cache-Control wins. Use Cache-Control for everything new; Expires only as a fallback for legacy caches. The most powerful Cache-Control combo for static assets is 'public, max-age=31536000, immutable' on fingerprinted URLs.
Are X-* headers safe to use?+
Mostly, but with caveats. RFC 6648 (2012) discourages the X- prefix for new standard headers, they tend to get standardized later without the X (X-Frame-Options is now in CSP frame-ancestors; X-Forwarded-For is now in Forwarded). For application-private headers (X-Request-ID, X-Tenant-ID), X- is still fine in practice. Never trust client-set X-Forwarded-For at the edge, only the leftmost N hops added by your trusted infrastructure are reliable.