SpunkArt
Command line and project setup

How to check HTTP response headers

Every web response starts with a status line and a block of headers: short name and value pairs that control caching, security, redirects and cookies. You can read them with one terminal command or two clicks in your browser.

Method 1: curl in a terminal

curl -I example.com
curl -sIL example.com
curl -s -D - -o /dev/null example.com
  • -I sends a HEAD request and prints only the headers.
  • -L follows redirects, printing each hop, and -s hides the progress meter.
  • The third form sends a normal GET, prints the headers (-D -) and throws away the body. Use it when a server answers HEAD differently from GET, which some do.

When you type a host without a scheme, curl uses plain unencrypted HTTP. Many sites answer that with a 301 to the secure version, so add -L to see the final response.

Method 2: browser DevTools

  1. Open the page, then open DevTools with F12, or Ctrl+Shift+I (Cmd+Option+I on a Mac).
  2. Choose the Network tab and reload the page.
  3. Click the first row, the document itself.
  4. Open Headers and scroll to Response Headers.

Tick “Disable cache” while DevTools is open if you want to see what the server sends now rather than a cached copy.

Reading the status line

CodeMeaningWhat to check
200OKNothing; the page was served
301 / 308Moved permanentlyThe Location header shows where
302 / 307Moved temporarilyFine for short-term moves; not for permanent ones
304Not modifiedThe browser’s cached copy is still valid
403ForbiddenPermissions, or a firewall rule
404Not foundThe path, or a missing redirect
500 / 502 / 503Server-side errorApplication logs, upstream servers, maintenance

Headers worth understanding

HeaderExample valueWhat it does
Content-Typetext/html; charset=utf-8Tells the browser how to treat the body
Cache-Controlpublic, max-age=3600How long caches may reuse the response (here one hour)
ETag"a1b2c3"A version tag the browser sends back to ask “has it changed?”
Location/new-page.htmlThe target of a redirect
Strict-Transport-Securitymax-age=31536000Tells browsers to use only the secure scheme for a year
Content-Security-Policydefault-src 'self'Limits where scripts, styles and images may load from
X-Content-Type-OptionsnosniffStops the browser guessing a different file type
Referrer-Policystrict-origin-when-cross-originControls how much of the address is sent to other sites
Set-Cookieid=x; Secure; HttpOnly; SameSite=LaxStores a cookie with its safety flags

The HSTS value 31,536,000 seconds is 365 days of 86,400 seconds each. On cookies, Secure keeps them off unencrypted connections, HttpOnly hides them from page scripts, and SameSite limits sending them with requests from other sites.

A quick audit routine

  1. Run curl -sIL example.com and count the hops. One redirect to the final address is ideal; chains waste time.
  2. Confirm the final status is 200 and the Content-Type is right.
  3. Check that HTML has a short cache time and versioned static files a long one.
  4. Look for the security headers in the table. A missing one is a to-do, not an emergency.
  5. Inspect each Set-Cookie for the three flags.

Common mistakes

  • Testing only one path. Headers can differ between the home page, static files and API routes.
  • Trusting a cached view. A CDN may serve old headers; look for an age or cache-status header and test again after a purge.
  • Turning on HSTS with a long max-age before every subdomain supports the secure scheme. Browsers will refuse the insecure ones until the time runs out.

Questions

Why is there no checker box on this page?

Fetching another site’s headers needs a network request from a server. The two methods above do the same job on your own machine.

Are header names case-sensitive?

No. content-type and Content-Type are the same header, and newer protocol versions send them in lowercase.