brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl -I shows the HTTP headers of a page without downloading it

Curl
~/tips/tip-curl-i-headers

curl -I https://example.com

Fetches only the response headers of a URL, to check redirects, status codes and caching.

When a site redirects somewhere strange or a cache does not behave, I want the headers, not the page. One flag gives me that.

Run it against a URL:

curl -I https://example.com
curl -IL http://example.com

-I sends a HEAD request and prints the status line and headers: the status code, content-type, cache settings, the location of a redirect. Add -L to follow redirects and see every hop on the way.

Caveat: a few servers answer a HEAD request differently from a normal GET, or refuse it. If the result looks odd, try curl -s -D - -o /dev/null URL, which does a real GET but prints only the headers.

Further reading: curl manual, On this site: curl -w prints the status code and timing and nothing else

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link