BetterShield
Appearance
Security headersHSTSHardening

WordPress security headers, explained: what each one does

· · 11 min read

Updated by Nazmul Hasan Rupok on

WordPress security headers are short instructions your site sends with every page, telling the browser how strict to be with it. They make selected browser behavior explicit, such as how to treat content types or whether another origin may frame a page. Defaults vary by browser and existing site policy.

BetterShield adds four standard headers with one switch, and keeps the two that need more care, HSTS and a content policy, behind choices of their own. Here is what each does and what it could affect.

Quick summary

  • A security response header tells the browser what to allow around a page. Visitors never see it.
  • Browser protections adds X-Content-Type-Options, X-Frame-Options, Referrer-Policy and Permissions-Policy, and, once its daily check has seen them, leaves to your server any it already sends.
  • HSTS has its own fix, Strict HTTPS (HSTS). Start at five minutes, because a six-month setting stays in browsers after you turn it off.
  • A content policy starts in report-only mode, so nothing is blocked. Enforcing is offered only after 7 days of watching with nothing on the list.
  • The finding “Your site doesn’t send some standard browser safety settings” is Low, costs 3 setup points, and has an Apply fix button.

What a security response header is

A browser that asks for a page gets the page plus a short block of labeled lines called headers. A security response header asks the browser to be stricter with the page than its default. It can affect visible behavior when a script, frame or other resource violates the policy.

To see them, open your browser’s developer tools, choose the Network tab, reload, and read the first request’s response headers.

Three browser boundaries

Match the header to the job

A header is useful when the browser receives the intended value.

  1. Response handling

    Type, framing and referrer rules.

  2. Future connections

    HSTS remembers HTTPS.

  3. Resource loading

    CSP limits permitted sources.

Response handling

What this means
The standard header group changes how browsers handle a response and how other sites can frame it. Correct MIME types and legitimate embeds still need testing.
Your next check
Inspect a real page response and test a partner embed, if your site has one.

Future connections

What this means
HSTS affects later connections to the host. Removing the server setting does not immediately clear stored browser policies.
Your next check
Confirm certificate renewal and start with the short, host-only setting.

Resource loading

What this means
Report-only observes; an enforced policy blocks disallowed resources. A policy permitting inline scripts has a different protection boundary from a strict policy.
Your next check
Exercise checkout, forms and embeds before deciding to enforce.
Inspect the final response after the CDN and cache. A switch in WordPress does not prove what visitors received.

The four WordPress security headers in one switch

Browser protections is under What browsers are told on BetterShield › Protection › Hardening. It adds four standard headers to front-end pages, the sign-in page, the REST API and the dashboard. WordPress already sends two of the four on the dashboard, so the fix adds the other two there.

Header and value sentWhat it tells the browserWhat it could affect
X-Content-Type-Options · nosniffUse the file type the server declares. Never guess.A file served with the wrong type may be refused as a script or stylesheet.
X-Frame-Options · SAMEORIGINOnly your own site may show these pages in a frame.Another site that frames your pages stops showing them. WordPress embeds of your posts keep working.
Referrer-Policy · strict-origin-when-cross-originOn cross-origin requests, send the origin rather than the full address; send no referrer on an HTTPS-to-HTTP downgrade.Sites you link to see the domain a visitor came from, not the page.
Permissions-Policy · browsing-topics=()Leave these pages out of the Topics API, which shares interest topics with advertisers.Ads on your pages that rely on that API get no topics from it.

Each closes a small gap. nosniff constrains type handling for relevant resource requests; it is not a general uploaded-file execution block. Framing rules reduce unwanted embedding. Referrer behavior also depends on browser defaults and other policy, and Topics support depends on the browser and its settings. These headers do specific jobs, not a complete browser-security reset.

Headers your server already sends are left alone

The fix never overwrites a header WordPress or another plugin has already set. Your web server can also add headers after WordPress has finished, out of a plugin’s sight, so once a day the fix asks your own front page which of the four the server sends, and leaves those to it. The card names them: “Your server already sends X-Frame-Options. This item leaves those to it and sends the rest.”

How to add security headers in WordPress with BetterShield

  1. On BetterShield › Protection › Hardening, find Browser protections under What browsers are told.
  2. Press Preview the change. It lists what applying would do and changes nothing.
  3. Turn the switch on. Once a visitor’s page has carried the headers, the card says Confirmed on a page a visitor received, with the time.
  4. To undo, turn the switch off.

It is also in Quick Setup’s Safe fixes, as Add security headers, and wp bettershield harden security_headers --dry-run previews it from the terminal (WP-CLI commands).

HSTS in WordPress: tell browsers to refuse plain HTTP

Strict-Transport-Security, or HSTS, tells a browser to use only HTTPS for your site for a set time. Once a browser has seen it, plain HTTP is refused for the whole period, and the browser cannot fall back if the certificate lapses. That is why it is not one of the four: in the fix’s own words, it is “the one that can take a site offline.”

Strict HTTPS (HSTS) has two choices:

FieldChoices
How long browsers should insistFive minutes, to prove it works (preselected) or Six months, once you have lived with the short one
Include subdomainsThis domain only (preselected) or Every subdomain as well
  1. Make sure the site address is HTTPS. If it is not, the fix shows Not available here.
  2. Keep the preselected choices and press Preview the change. It shows the exact header: max-age=300.
  3. Turn it on, then use the site as visitors do: pages, forms, sign-in and the dashboard.
  4. When you are confident, turn the switch off, choose Six months, once you have lived with the short one, and turn it on again. The header becomes max-age=15768000.

It goes out on HTTPS responses only, and one WordPress or another plugin already sets is left alone; if your web server adds HSTS itself, send it from one place only. If the certificate expires within 21 days, the fix asks you to renew it first.

Why a long setting stays after you turn it off

Turning the fix off stops sending the header, but it cannot reach browsers that already saw it. The short policy expires five minutes after its last HSTS response, provided another applicable policy does not remain. At six months, they keep insisting on HTTPS until the time runs out.

Every subdomain as well is only for sites where every subdomain is on HTTPS too, including forgotten ones such as a staging or mail subdomain. For the same reasons, a connected AI assistant may apply only the five-minute, this-domain-only form. Six months or every subdomain waits for you.

Content-Security-Policy in WordPress: report first, enforce later

A Content-Security-Policy lists where a page may load scripts, styles, images, fonts and frames from, and the browser blocks everything else. It is a strong defense against injected script, and the header most likely to break a site’s own analytics, embeds and payment scripts.

Script-blocking policy sends the policy on front-end pages in report-only mode. Nothing a visitor loads changes. Browsers only report what would have been blocked.

The starting policy allows your own site, inline scripts and styles included, so the reports show what your pages load from elsewhere.

  1. Turn on Script-blocking policy under What browsers are told. The card says “Watching. Nothing has been reported yet.”
  2. As reports arrive, read What the policy would have blocked. Each line names a rule and the origin of what it would have blocked, most frequent first. The full address is never kept.
  3. Start enforcing this policy is offered only once the fix has been watching for 7 days and its list is empty. Anything on the list holds it back. Time and turning the fix off and on do not clear it, but Clear this list does, and a reported source you recognize can be added with Allow; either starts the 7 days again. Until then the card says why, such as “Nothing has been reported in 3 of the 7 days this waits for.”
  4. Enforcing asks you to confirm. Go back to watching returns to report-only at once and is never held back.

A week covers traffic a quiet afternoon misses, such as a checkout used twice a week. Turning the fix off and on again restarts it in report-only and restarts the 7 days; the list is kept.

For many sites the list is the useful part: a plain picture of what the pages pull in from elsewhere. Enforcing is for a site whose list stays empty.

The audit finding: “Your site doesn’t send some standard browser safety settings”

The audit reports this finding when any of the four headers is missing. It sits in the Public information about your site area at Low severity and takes 1 point from site health while open.

Explain on BetterShield › Findings says under Why it matters: “Without them a browser falls back to its most permissive behavior.” Under Before you act, it says almost nothing: “If another site legitimately embeds your pages in a frame, that embed would stop working.”

Apply fix turns on Browser protections straight away; undo it from Protection › Hardening. The finding covers the four headers only. HSTS and the content policy are your choices on the Hardening screen. See the Score and findings guide and the checklist.

Verify the response, then the user journey

Check the actual document request in browser developer tools after the change. Start with a signed-out visit, disable the browser cache for the test, and inspect the final response after redirects. A header on a redirect is not proof that the destination page carries the same value.

Repeat for the home page, a normal post, sign-in and a representative form or checkout. A CDN may serve cached HTML without running WordPress, and the host may add headers after the plugin has finished. If the response is missing a value or contains duplicates, identify its owner at each layer before adding another copy.

Worked example (fictional): a partner embeds a booking page in an iframe. After enabling the standard headers, the page works when opened directly but the partner’s frame fails. The browser’s refusal is the behavior to investigate. Decide with the developer which pages may be embedded and by whom; do not disable every security header just to recover one intended embed.

Acceptance means both the intended header and the intended workflow are present. For nosniff, check that scripts and styles have correct content types. For framing rules, test the permitted embed. For HSTS and CSP, use their separate staged rollout guides. A scanner’s green label alone cannot make those compatibility decisions for you.

Common mistakes

  • Starting HSTS at six months. Prove it at five minutes first. A long setting stays in browsers after you turn it off.
  • Choosing Every subdomain as well without checking each one. A forgotten staging or mail subdomain on plain HTTP becomes unreachable in those browsers.
  • Forgetting that another site frames yours. If a partner site shows your pages in a frame, SAMEORIGIN stops it. Check before you apply.
  • Expecting HSTS behind a proxy that handles HTTPS. If WordPress sees requests as plain HTTP, the fix says so. Confirm the trusted-proxy HTTPS configuration with your host; do not trust arbitrary forwarding headers from visitors.

Frequently asked questions

Do security headers change how my site looks?

Headers are not visible page content, but enforcing them can affect frames, scripts and other resources. Test the workflows your site needs after changing them.

My host already adds some of these. Will visitors get them twice?

Not once the first daily check has run. The fix leaves any of the four already present untouched, and once a day it checks which ones your web server sends on its own and leaves those to the server. Until that check has run, a header your server adds on its own can arrive twice. The same goes for a host that blocks the site’s requests to itself, where the check learns nothing.

Does BetterShield add HSTS preload?

No. Preload puts a site on a list built into browsers, and removal takes months, so the fix never adds it.

Can I turn the headers off again?

Yes. Turn the switch off on Protection › Hardening, or run wp bettershield harden security_headers --undo --user=<login>. The exception is HSTS: browsers that already saw a six-month setting keep it until it expires.

Conclusion

WordPress security headers are a small, quiet layer: four lines that make the browser stricter, one that insists on HTTPS, and one that limits where a page may load from. Turn on Browser protections first. Then prove HSTS at five minutes, and let a content policy report for a week before you think about enforcing it.

BetterShield is free on WordPress.org. The Hardening guide covers all 30 fixes, and the WordPress security checklist shows where this finding fits.

Close the open doors today

Install the free plugin. The first audit runs when you activate it, and all but one of the fixes wait for your choice.

Requires WordPress 6.7 or newer and PHP 8.0 or newer.

Get BetterShield