Back to lessons

Apple Terminal

Check a URL Without Downloading the Page

A developer needs to confirm whether a local or remote URL returns the expected status, redirect, or content type.

Command

curl -I https://example.com

What changed

Nothing changes locally. The command makes a HEAD request and prints response headers.

Danger

safe

When to use it

Use for quick checks of local dev servers, redirects, CDN headers, and status codes.

When not to use it

Do not use when the server handles HEAD differently from GET. In that case, use curl -i.

Undo or recovery

No undo needed because this command is read-only locally.

Expected output

HTTP status line and headers such as content-type, cache-control, and location.

demo script

Disposable terminal steps

  1. printf '%s\n' 'HTTP/2 200' 'content-type: text/html' 'cache-control: max-age=300'
  2. printf '%s\n' 'HTTP/2 301' 'location: https://www.example.com/' | awk 'BEGIN{IGNORECASE=1} /HTTP|location|content-type|cache-control/'

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ printf '%s\n' 'HTTP/2 200' 'content-type: text/html' 'cache-control: max-age=300'
HTTP/2 200
content-type: text/html
cache-control: max-age=300
::exit-code::0
$ printf '%s\n' 'HTTP/2 301' 'location: https://www.example.com/' | awk 'BEGIN{IGNORECASE=1} /HTTP|location|content-type|cache-control/'
HTTP/2 301
location: https://www.example.com/
::exit-code::0

YouTube Short

Check headers fast.

curl dash I asks for headers only. It quickly shows status codes, redirects, content type, and cache behavior.

LinkedIn hook

Before opening a broken page in five browsers, ask the server for headers.

Question: What header do you check first when a web page behaves strangely?

experiments

A/B tests to run

Metric: click_through_rate

A: Demo with localhost.

B: Demo with example.com.