The Page Loads Fine — But Its Headers Are Telling a Different Story
Last month a client's site passed every check I could think of. The pages rendered fast. The design was clean. Lighthouse gave it a green score. Then their security auditor sent back a one-page report that read like a fa
Last month a client's site passed every check I could think of. The pages rendered fast. The design was clean. Lighthouse gave it a green score. Then their security auditor sent back a one-page report that read like a failing grade.
Nothing on the page was broken. The problem was invisible — in the response headers. The site was missing four of the five security headers that browsers actually enforce, its pages were not being cached at all, and the server was happily announcing its exact software version to anyone who asked.
I have checked headers on dozens of sites since, and the pattern repeats. Headers are the part of a response nobody looks at until something goes wrong. Here is what they are, what they control, and the five checks I run on every site now.
What response headers actually are
Every time a browser requests a page, the server sends two things back: the HTML you see, and a set of headers you do not. Headers are short key-value instructions that travel with the response. They tell the browser how to handle the page, how long to cache it, which resources it may load, and what to do when something looks suspicious.
You can see them in any browser. Open DevTools, go to the Network tab, click a request, and look at the Response Headers section. Most developers have never opened that panel. That is the problem.
The HTML is the visible half of a response. The headers are the operating instructions. A site can look perfect and still be shipping instructions that weaken its security, waste bandwidth, or confuse search engines.
The five security headers that matter
There are dozens of response headers, but five do most of the security work. If you check nothing else, check these.
Strict-Transport-Security (HSTS) tells browsers to always use HTTPS for your site, even if a link or bookmark points to the plain HTTP version. Without it, a visitor who types your domain without the scheme can be downgraded to an unencrypted connection on the first request. With it, the browser refuses to make that mistake.
Content-Security-Policy (CSP) controls which scripts, styles, and other resources a page is allowed to load, and from where. It is the strongest defence against cross-site scripting, because even if an attacker injects a script into your page, the browser will refuse to run it if the source is not on your approved list.
X-Content-Type-Options with the value nosniff stops browsers from guessing a file's type. Without it, a browser can decide that a file your server called plain text is actually executable script — and run it. This is how some old MIME-sniffing attacks worked.
X-Frame-Options (or the CSP frame-ancestors directive) stops other sites from embedding your pages in a frame. Without it, your login page can be framed inside an attacker's page in a clickjacking attack, where the visitor clicks something they cannot see.
Referrer-Policy controls how much of your URL leaks to other sites when a visitor clicks an outbound link. A strict policy keeps internal paths and query strings out of the referrer header that other sites receive.
None of these headers changes how a page looks. That is exactly why they get skipped. They are invisible work, and invisible work is the first thing cut under deadline pressure.
The missing-header trap: everything works until it doesn't
Here is the uncomfortable truth about security headers: a site missing all five will work perfectly. Pages load. Users log in. Nothing looks wrong. The protections these headers provide only matter when someone is actively attacking the site, or when an auditor checks.
That is why I now treat a header check as part of every launch checklist, next to the SSL certificate and the sitemap. A missing HSTS header is not a cosmetic issue. It is an open door that only shows itself when someone walks through it.
The same logic applies to the audit findings I see most often. The report does not say "your site is broken". It says "your site is unprotected". Those are different sentences, and the second one is the one that costs a client a contract.
Caching headers: the silent performance leak
Security is only half the story. The other half is caching, and it is where headers quietly cost real performance.
Cache-Control tells browsers and CDNs how long a response can be reused before checking back with the server. When it is missing, or set far too conservatively, every repeat visit re-downloads content that has not changed. Multiply that by every page, every asset, and every visitor, and the cost adds up.
The fix is not complicated, but it is easy to get wrong in the other direction. Versioned files such as app.3f9a.css can be cached for a year, because the filename changes when the content changes. HTML pages usually need a short lifetime, so updates reach visitors quickly.
The classic mistake is caching HTML for a year and then wondering why visitors keep seeing the old homepage. The other classic mistake is caching nothing at all, and wondering why repeat visits feel slow. Both show up in the headers, and both are visible in a single check.
The headers that give away too much
Some headers do not protect or speed anything up. They just talk too much. The Server header announces the server software and often its exact version. X-Powered-By does the same for the application framework.
Neither header breaks anything. But exact version numbers make it slightly easier for an attacker to match your stack against known vulnerabilities. Most teams strip or generalize these headers as a minor hardening step. It is not the most critical fix on the list, but it is free, and there is no reason to advertise your stack to the whole internet.
There is one more header worth watching for, and it is the one that has cost people search traffic: X-Robots-Tag. When it carries noindex, the page is hidden from search engines — even when the HTML looks completely fine. I have seen a staging configuration leak into production this way, with the header quietly deindexing pages while the team wondered why rankings were falling.
How to check headers in under a minute
You do not need a terminal or a curl command to do this, although curl works fine. The fastest way is a purpose-built tool: paste the URL, run the check, and read the findings in plain English.
When you run an http header check, you get the full response header list alongside the status code, plus a plain-English reading of what is missing. It flags the five security headers above, a missing Cache-Control, and Server or X-Powered-By values that reveal version details. It does not follow redirects, so you see the response for the exact URL you entered — which matters, because a redirect's headers are not the page's headers.
The check takes seconds. What takes longer is deciding what to do with the findings, which brings me to the part most articles skip: the order in which to fix them.
The fix order I actually use
Not every missing header is equally urgent, and fixing them in the wrong order creates new problems. This is the sequence I follow.
First, set X-Content-Type-Options: nosniff and Referrer-Policy. Both are safe to add everywhere. They break nothing and close real gaps. There is no reason to delay them.
Second, add X-Frame-Options or a CSP frame-ancestors directive. Unless your site is designed to be embedded in other pages, framing should be blocked. Check first that no legitimate integration depends on framing — some payment widgets do.
Third, enable HSTS — but only once HTTPS works everywhere on the site, including subdomains you plan to include. Browsers remember HSTS for the whole max-age period, and they will refuse plain HTTP for that entire time. Enabling it while some subdomain still serves HTTP will lock visitors out of that subdomain.
Fourth, roll out Content-Security-Policy gradually. Start with Content-Security-Policy-Report-Only and watch the violation reports for a week. This shows you what the policy would block before it blocks anything. Enforcing a strict CSP on a live site without that step is how you break your own scripts in production.
Finally, fix caching. Set long lifetimes on versioned static assets and short lifetimes on HTML. Then re-check, because caching is set at several layers — the server, the CDN, the application — and one layer can override another.
The checks that catch real problems
Beyond the five security headers, there are a few header findings that have saved me real debugging time.
A missing Content-Type, or one that does not match the file, explains mysterious rendering problems. A Location header on a page that should return 200 tells you a redirect is firing that you did not expect. And a Set-Cookie header without the Secure and HttpOnly flags is a session cookie that can travel over plain HTTP or be read by JavaScript.
The pattern is always the same: the page looks fine, the headers disagree, and the headers are right. When a site misbehaves in a way the HTML cannot explain, the headers are the next place to look.
Make it a habit, not a one-off
The reason headers stay unchecked is that nobody owns them. The developer sets them, the hosting provider overrides some of them, the CDN adds its own, and the application sets a few more. Responsibility is spread across four layers, so no single person ever reads the final result.
That is why a header check belongs in the launch checklist and in the periodic audit. Run it after a server migration, after a CDN change, after a plugin update that touches security settings, and after any incident. It takes under a minute, and the findings are either reassuring or actionable. There is no third outcome.
The page your visitors see is only half the response your server sends. The other half is a set of instructions that decides how secure, how fast, and how visible that page really is. Check it before someone else does — because auditors, attackers, and search engines already are.
Further reading
- The full list of HTTP response headers, with definitions: MDN — HTTP headers
- The OWASP cheat sheet on security headers: OWASP — HTTP Security Response Headers Cheat Sheet
- How caching headers work, from Google's web fundamentals: Google — HTTP Caching
If you have ever found a header problem that explained a bug nobody could reproduce, I would like to hear about it. The best checklists come from production incidents, and this one is still growing.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.