What Are HTTP Security Headers?
Every time a browser requests a page, the server sends back a response with two parts: the headers (metadata) and the body (HTML content). Most developers only think about the body — but headers are where you tell the browser how to behave when rendering your page.
Security headers are a subset of these response headers. They instruct the browser to enforce specific security policies: block HTTP, prevent framing, restrict scripts, and more. They don't require any changes to your application logic — just your server configuration.
Key insight: Security headers are a defense-in-depth measure. They don't replace secure coding, but they limit the damage when something goes wrong.
The Six Headers You Should Know
max-age (in seconds). This prevents protocol downgrade attacks
where an attacker intercepts an HTTP request before the redirect to HTTPS can happen.
<iframe> on another site.
This blocks clickjacking attacks, where an attacker overlays an invisible frame
of your site over their own page to trick users into clicking things they didn't intend to.
Referer header when
navigating between pages. Without this, clicking a link on your site could expose full URLs
(including query parameters with sensitive data) to third-party sites.
How to Check Your Site
You can use the HTTP Security Header Checker built into this site. Enter any URL and you'll get an instant breakdown of which headers are present, what values they have, and a security score out of 100.
Try checking a site you own, or a well-known site like github.com to see what a well-configured set of headers looks like in practice.
How to Add Them
The implementation depends on your stack. In Django, the
SecurityMiddleware handles several of these automatically when you set the right
settings in settings.py:
For Nginx, you add them directly to your server block. For Apache,
use the Header always set directive. Most modern hosting platforms also let you
configure headers through their dashboard.
Final Thoughts
Security headers are one of the highest-leverage improvements you can make to a web application. They take minutes to configure and protect every user who visits your site — no authentication, no database, no application code required.
The next time you deploy a site, run it through a header checker before you ship. It's a quick win that most developers skip.