Security headers and HTTPS: what your server tells the browser
Operations and securityWhich headers protect your visitors' browser, why the permissive default applies without them, and in which order to introduce them safely.
13 min read
By Timo Wessels Published
Security headers are instructions your server sends to the browser with every response and that switch on protective measures there: connect only encrypted, run no foreign scripts, do not allow the page to be embedded in foreign frames.
If the server does not send a header, the browser’s default behaviour applies, and in most cases that is the permissive one. That is why these headers are missing on so many websites: nobody switched them off, nobody ever switched them on. The foundation for everything is HTTPS, the encrypted connection. Without it most headers do not work at all.
The most important points first:
- Security headers are instructions your server sends to the browser with every response and that switch on protective measures there.
- If the server does not send a header, the browser’s default behaviour applies, and that is mostly the permissive one.
- The foundation is HTTPS, the encrypted connection. Without it most headers do not work.
What these headers do and what they do not
Security headers restrict what the browser of your visitors allows on your page. An example: without a matching instruction, any foreign website may embed your page in a frame. MDN writes: if no header is sent and there is no other mechanism, the browser allows other sites to embed the document. An attacker can then lay your real page invisibly over their own and let visitors click on buttons they do not see. That is called clickjacking. With the matching header the browser refuses the embedding.
The OWASP Secure Headers Project, a collection of recommendations by the Open Worldwide Application Security Project Foundation, describes itself like this: it provides technical information and tools about HTTP security headers.
Important for classification: the headers do not replace secure software. They are a second line of defence that takes hold when something has gone wrong elsewhere. They do not change the look and are server configuration, not development. That is my assessment.
HTTPS is the foundation
What a certificate does: the connection between visitor and server is encrypted and protected against change on the way. web.dev names both: HTTPS prevents third parties from manipulating the communication, for example injecting ads. And it prevents unencrypted requests from allowing conclusions about the behaviour and identity of your visitors, also on pages without sensitive data. Many newer browser features require HTTPS anyway.
What it does not do: it says nothing about the trustworthiness of the operator. That is why Google replaced the lock in Chrome with version 117 in September 2023 with a neutral settings icon. The Chrome team’s reasoning: in a 2021 study only 11 percent of participants understood what the lock means exactly, and nearly all phishing sites use HTTPS themselves.
For Google HTTPS counts: since 2014 it has been a ranking signal, then explicitly a lightweight one. Google’s guidance on page experience points to the HTTPS report in Search Console: are your pages served securely?
Certificates cost nothing today. Let’s Encrypt issues them free of charge, currently with a validity of 90 days. The validity is falling: from 10 February 2027 Let’s Encrypt issues certificates of 64 days in its default profile, from 16 February 2028 of 45 days. Without working automatic renewal this no longer works. Let’s Encrypt writes: most users with automatic issuance do not need to change anything, but should check that their automation copes with shorter validity. A hard-coded renewal interval of 60 days is no longer enough at 45 days.
Three things need checking:
- Does the renewal run? Automation can fail silently. An expired certificate produces a full-page warning in the browser.
- Does the certificate cover all address variants? With and without
www.and every subdomain in use. - Is the unencrypted version redirected permanently? For a move Google recommends permanent server-side redirects with
301or308, and no long chains.
Mixed content
Mixed content is a page delivered encrypted that loads individual files unencrypted.
What counts: everything the browser loads, so scripts, stylesheets, images, fonts, frames, media. What does not count: a link to an unencrypted page. That is navigation and not loading. Some check tools report it as an error anyway. That is my experience.
What happens: according to MDN, browsers upgrade images, audio and video to HTTPS automatically. Insecure requests for everything else are blocked. The page then looks broken or no longer works properly. And an image whose server cannot do HTTPS is missing despite the switch.
The most common cause is a move from HTTP to HTTPS in which old addresses stayed in the database, in posts, widgets and theme settings. The fix is a search and replace in the database: http://yourdomain.com with https://yourdomain.com. Take a backup first. That is my practice.
The headers one by one
HSTS: encrypted only
What it says: this host can be reached only over HTTPS, for the stated time in seconds. According to MDN, the browser then no longer offers a way to click past a certificate error.
The use: whoever types the address without a protocol otherwise first opens an unencrypted connection and is only then redirected. This first request is vulnerable. With HSTS it drops out from the second visit.
- The duration:
max-age. For the browsers’ preload list at least one year (31536000) is mandatory, OWASP recommends two years (63072000). - The reach: without
includeSubDomainsthe rule applies only to the host that sends it. The main domain looks protected, subdomains remain reachable unencrypted.
The precondition must be taken seriously. Browsers ignore the header if it arrives over unencrypted HTTP. The risk lies elsewhere: with includeSubDomains the rule also applies to a test environment or an old tool on a subdomain. If that has no valid certificate, it is blocked for every visitor who visited the main domain before, because the browser offers no way past the warning. So check all subdomains first.
The preload list is a decision, not a setting. With preload you apply for inclusion in a list that browsers know before the first visit. For that, a max-age of at least one year and includeSubDomains are mandatory. hstspreload.org warns that inclusion cannot easily be undone and that a removal takes months to reach users. Forgoing it is a conscious stance, not an omission.
CSP: which sources may load
What it says: from which addresses each kind of resource may be loaded and whether code may run directly in the page. MDN names as the main purpose protection against injected code (cross-site scripting) and against clickjacking.
This is the most effective and the most laborious header. Set correctly, it prevents injected code from being executed. Set wrongly, it paralyses parts of the website.
Two settings weaken it strongly: unsafe-inline allows code directly in the page, unsafe-eval dynamically generated code. MDN advises nonces or hashes instead. Many common WordPress themes and plugins still cannot do without unsafe-inline. Then a CSP with this gap is still better than none. That is my assessment.
The sensible way to introduce it is in stages:
- First set
Content-Security-Policy-Report-Only. This header reports violations but blocks nothing. Best on a test environment. - Evaluate the reports until only expected resources show up. Filter out reports that come from visitors’ browser extensions. Otherwise you search for errors that do not exist on your page.
- Then switch to the enforcing header.
X-Content-Type-Options: no guessing of file types
What it says: nosniff. The browser sticks to the stated file type instead of guessing it from the content. Scripts and stylesheets with the wrong type are blocked. One value, practically no risk of side effects, the simplest item on this list.
Protection against embedding
There is the older header X-Frame-Options with DENY or SAMEORIGIN and the frame-ancestors setting in the CSP. OWASP writes that frame-ancestors supersedes the older header in browsers that support it. For more comprehensive options MDN points to frame-ancestors. X-Frame-Options remains useful for older browsers. frame-ancestors can name individual allowed addresses and works only as a header, not as a meta tag.
Referrer-Policy
What it says: how much of the current address is sent along when someone clicks an external link or the page loads something external. That matters if your addresses are descriptive, containing identifiers or search terms.
The value strict-origin-when-cross-origin sends the full address within your site, only the domain to foreign targets and nothing at all to unencrypted targets. According to MDN, that has been the default behaviour since the specification of November 2020 if no header is set. The header still records the intention and also applies where a browser is preset differently.
Permissions-Policy
What it says: which browser features the page and embedded frames may use, such as camera, microphone and location. The practical form is an empty allowlist: camera=(), microphone=(), geolocation=(). That blocks these features for the page and every frame in it, for example an embedded map. MDN points out that the header is not Baseline, that is, it does not work in some of the most widely used browsers. It does no harm there, but has no effect either.
Headers whose right state is absence
There are headers whose presence is the flaw. A check report that criticises their absence is out of date.
| Header | Status | What to do |
|---|---|---|
X-XSS-Protection |
deprecated; according to MDN can itself create holes in otherwise safe sites | leave out or set to 0 (as OWASP recommends), use CSP |
Expect-CT |
deprecated; Chromium has enforced certificate transparency since version 107 anyway | remove |
Public-Key-Pins |
marked by OWASP as no longer to be used, removed from Chromium in 2018 | remove |
The trap of double configuration
A header can be set in two places: in the web server and in the application, such as WordPress or a plugin. If both set the same header, the recipient combines the values according to the HTTP standard (RFC 9110) into one field with a comma, for example nosniff, nosniff.
For check tools that is a trap: whoever compares the value exactly with the expected one reports a host that is actually configured as faulty. And with contradictory values nobody knows for sure which one applies. Set each header in exactly one place, then the next change also has to be made in only one place. That is my practice.
What else the server gives away
- Version details in headers.
ServerandX-Powered-Byoften name software and version. OWASP recommends removingX-Powered-Byand removingServeror making it uninformative, because attackers find vulnerabilities more easily with it. - Error messages in the page content. A displayed PHP error shows file paths and versions. WordPress itself advises against using the debug tools on live sites. If you need errors:
WP_DEBUG_LOGon,WP_DEBUG_DISPLAYoff. The error lands in the log instead of on the page.
How to check it yourself
- Online check service for security headers: enter the address, read the list of set and missing headers. The grade is not the goal, the list below is the useful part. The outdated headers from the table above do not belong on the list of faults.
- By hand: developer tools (F12), Network tab, reload the page, click the first line, read the response headers.
- Certificate: click the symbol at the left of the address bar. Issuer, expiry date and covered addresses are there.
- Mixed content: developer tools, Console tab, reload the page. Blocked resources are listed there in plain text.
- The simplest check: open your site with
http://. You must land onhttps://through a permanent redirect.
What you can do
Ordered by effort and risk:
- Check certificate, renewal and permanent redirect. Precondition for everything else.
- Remove mixed content. Visible to every visitor.
- Set the simple headers:
X-Content-Type-Options,X-Frame-Options,Referrer-Policy,Permissions-Policy. A few lines, hardly any risk to function. - Remove outdated headers and switch off version details and error output.
- Set HSTS.
includeSubDomainsonly when every subdomain has a valid certificate. Decide consciously aboutpreload. - CSP last, in stages through the report mode, starting on a test environment. The only item that costs serious time, and the only one that can paralyse the website.
Check after every change: home page, a subpage, a form, an embedded video. Headers take effect at once and on all pages.
And a classification of the weight: Patchstack reports in its 2026 report that 91 percent of the new WordPress vulnerabilities were found in plugins. In two tests the usual protection layers of hosts and servers stopped only 26 and 12 percent of attacks. For the most exploited vulnerabilities the median time to mass exploitation was five hours. Security headers are therefore no substitute for updates, few plugins and good credentials. They are cheap, they help, and they are the second row, not the first.
Sources
- MDN, Strict-Transport-Security — effect,
includeSubDomains, requirements forpreload, header over HTTP is ignored, no clicking past certificate errors: developer.mozilla.org(external site: developer.mozilla.org) - hstspreload.org — requirements of the preload list, removal takes months: hstspreload.org(external site: hstspreload.org)
- MDN, Content Security Policy — protection against XSS and clickjacking,
unsafe-inlineandunsafe-eval, nonces and hashes: developer.mozilla.org(external site: developer.mozilla.org) - MDN, Content-Security-Policy-Report-Only — report without blocking: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, X-Content-Type-Options —
nosniff, blocked scripts and stylesheets: developer.mozilla.org(external site: developer.mozilla.org) - MDN, X-Frame-Options — values and reference to
frame-ancestors: developer.mozilla.org(external site: developer.mozilla.org) - MDN, CSP frame-ancestors — not usable as a
metatag: developer.mozilla.org(external site: developer.mozilla.org) - MDN, Referrer-Policy —
strict-origin-when-cross-originas default since November 2020: developer.mozilla.org(external site: developer.mozilla.org) - MDN, Permissions-Policy — empty allowlist, effect on frames, limited support: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, X-XSS-Protection — deprecated, can create holes: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, Expect-CT — deprecated since Chromium 107: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, Mixed content — upgrade of images and media, blocking of all other resources: developer.mozilla.org(external site: developer.mozilla.org)
- OWASP, Secure Headers Project — purpose of the project: owasp.org(external site: owasp.org)
- OWASP, HTTP Headers Cheat Sheet — recommended values, HSTS with two years,
frame-ancestorssupersedesX-Frame-Options, Public-Key-Pins, Server and X-Powered-By,X-XSS-Protection: 0: cheatsheetseries.owasp.org(external site: cheatsheetseries.owasp.org) - IETF, RFC 9110: HTTP Semantics, section 5.3 — combining repeated fields with a comma: rfc-editor.org(external site: rfc-editor.org)
- web.dev, Why HTTPS matters — protection against manipulation, also for pages without sensitive data: web.dev(external site: web.dev)
- Chromium Blog, An Update on the Lock Icon — Chrome 117, 11 percent of study participants: blog.chromium.org(external site: blog.chromium.org)
- Google Search Central Blog, HTTPS as a ranking signal — lightweight signal since 2014: developers.google.com(external site: developers.google.com)
- Google Search Central, Understanding page experience — HTTPS report as a check aid: developers.google.com(external site: developers.google.com)
- Google Search Central, Site moves with URL changes — permanent redirects with 301 or 308: developers.google.com(external site: developers.google.com)
- Let’s Encrypt, FAQ — free certificates: letsencrypt.org(external site: letsencrypt.org)
- Let’s Encrypt, Decreasing Certificate Lifetimes to 45 Days — schedule 2027 and 2028: letsencrypt.org(external site: letsencrypt.org)
- WordPress Developer Resources, Debugging in WordPress — no debug tools on live sites, log instead of display: developer.wordpress.org(external site: developer.wordpress.org)
- Patchstack, State of WordPress Security in 2026 — 91 percent in plugins, 26 and 12 percent blocked, five hours median: patchstack.com(external site: patchstack.com)
- Own practice — the order of steps, the database search for mixed content, each header in exactly one place.