Inspect Response Headers

Fetch a URL and inspect all response headers including custom ones.

Code

Utilities
const response = await fetch('https://httpbin.org/response-headers?X-Custom=test&Cache-Control=max-age=3600');

const headers = {};
response.headers.forEach((value, key) => {
  headers[key] = value;
});
headers;
Browser·fetch() may be limited by CORS

Common Response Headers

HeaderPurpose
content-typeResponse format
content-lengthSize in bytes
cache-controlCaching rules
set-cookieCookie to store
locationRedirect URL
x-ratelimit-*Rate limit info

More JavaScript Snippets