๐Ÿ“‹developer

HTTP Headers Every Developer Should Know (Not Just the Obvious Ones)

HTTP headers control security, caching, content negotiation, and authentication. Most developers know a handful. Here are the ones that make a real difference.

PSBy Priya Shah ยท Senior Software EngineerJanuary 20, 2026Updated February 22, 20267 min read
Free to read

Advertisement

Frequently Asked Questions

What is the difference between request headers and response headers?+
Request headers are sent by the client (browser, API consumer) to tell the server about the request context: what content types it accepts (Accept), authentication credentials (Authorization), what host it's connecting to (Host), caching preferences (Cache-Control, If-None-Match), the origin of the request (Origin), and browser/client information (User-Agent). Response headers are sent by the server to tell the client how to handle the response: the content type (Content-Type), caching rules (Cache-Control, ETag, Last-Modified), security policies (Content-Security-Policy, Strict-Transport-Security), allowed CORS origins (Access-Control-Allow-Origin), and cookie instructions (Set-Cookie).
What security headers should every web application include?+
The essential security headers are: Strict-Transport-Security (HSTS) to force HTTPS connections; Content-Security-Policy (CSP) to restrict which resources the page can load, preventing XSS; X-Content-Type-Options: nosniff to prevent MIME type sniffing; X-Frame-Options or frame-ancestors CSP directive to prevent clickjacking; Referrer-Policy to control what referrer information is sent with links; and Permissions-Policy to restrict browser feature access (camera, microphone, geolocation). HSTS and CSP are the highest-impact ones. SecurityHeaders.com provides a free scanner showing which headers your site is missing and why they matter.
How does HTTP caching work through headers?+
The server sets Cache-Control in the response to instruct caches how long to store the response: max-age=3600 means cache for one hour, no-cache means revalidate with the server before using cached version, no-store means never cache. ETag provides a fingerprint of the content โ€” when the browser has a cached version, it sends If-None-Match: [etag] with the next request; if the content hasn't changed, the server returns 304 Not Modified without sending the body. Last-Modified and If-Modified-Since work similarly using timestamps. For static assets with versioned filenames (bundle.abc123.js), use max-age=31536000, immutable to cache for a year with no revalidation.

Advertisement

๐Ÿ”ง Free Tools Used in This Guide

PS

Priya Shah

Senior Software Engineer ยท 9+ years experience

Priya has nine years of experience building distributed systems and developer tooling at two B2B SaaS companies. She writes about APIs, JSON/JWT workflows, regex, DevOps, and the small utilities that make debugging faster at 2am.

View all posts by Priya Shah โ†’

Tags:

httpheadersweb-developmentsecuritycaching