cURLコマンドでヘッダー情報のみ出力する
-I
または --head
オプションでできる。
$ curl -I https://example.com
HTTP/2 200
content-encoding: gzip
accept-ranges: bytes
age: 500505
cache-control: max-age=604800
content-type: text/html; charset=UTF-8
date: Fri, 01 Mar 2024 05:28:20 GMT
etag: "3147526947"
expires: Fri, 08 Mar 2024 05:28:20 GMT
last-modified: Thu, 17 Oct 2019 07:18:26 GMT
server: ECS (sac/257F)
x-cache: HIT
content-length: 648
curl --head https://example.com
HTTP/2 200
content-encoding: gzip
accept-ranges: bytes
age: 59493
cache-control: max-age=604800
content-type: text/html; charset=UTF-8
date: Fri, 01 Mar 2024 05:28:50 GMT
etag: "3147526947"
expires: Fri, 08 Mar 2024 05:28:50 GMT
last-modified: Thu, 17 Oct 2019 07:18:26 GMT
server: ECS (sac/2520)
x-cache: HIT
content-length: 648
cURL の man を抜粋
-I, --head
(HTTP FTP FILE) Fetch the headers only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on an FTP or FILE file, curl displays the file size and last modification time only.
Providing --head multiple times has no extra effect. Disable it again with --no-head.
Example:
curl -I https://example.com
See also -G, --get, -v, --verbose and --trace-ascii.
Read other posts