An HTTP header is one line of metadata, a name and a value, that travels with a request or a response and describes it. The body holds the page itself, and the headers say what the body is, how long to keep it, and what to do next.
Both sides send them. Your client attaches request headers, such as the name it goes by. The server answers with response headers, and a scraper gets most of its useful facts from those. This page shows the headers of one fetch and marks six to read on every response. The rest of the subject sits in the web scraping guide, which this page narrows to one piece of the wire.
What a header is made of
A header is a field name, a colon and a value. MDN's overview of HTTP explains why the design lasted: "New functionality can even be introduced by an agreement between a client and a server about a new header's semantics." A client and a server can start using a new header without changing the protocol.
Names are not case sensitive. RFC 9110 says "Field names are case-insensitive", so Content-Type and content-type are the same field. Code that looks a header up by its exact capitalisation will miss it on some servers and some HTTP versions, and that is a bug that shows up only on certain sites.
A server may also send the same name twice. Treat a header as something that can have more than one value, and not as a single string you can always count on.
The six to read on every response
You do not need every header. Most of what a response carries is for browsers and for the site's own caches. Six decide what a scraper does next.
content-typetells you what the body is: HTML, JSON, a PDF, an image. It often gives the character set too, though it can leave it out. Read it before you parse, because a page that saystext/htmlwill not parse as JSON, however much you want it to.cache-controlis the site's statement of how long a copy stays fresh, or that it should not be kept at all. It tells you how often there is a point in asking again. An olderexpiresheader can say the same with a date.etagis a label for one version of the page. Send it back later, and the server can answer that nothing changed.last-modifiedis a date for the same purpose. A server can send it with anetag, in place of one, or neither. Both power conditional requests, which save you from downloading a page you already have.retry-aftershows up with a 429 or a 503 and says how long to wait before asking again. It is the one header that sets your pace for you. See Retry-After.locationcomes with a redirect and holds the address to ask for next. A 3xx response whoselocationyou never follow is a page you never read. Not every 3xx has one: a 304 answers a conditional request and has nothing to follow. The status codes page lists which codes carry it.
A header that is absent is an answer too. Plenty of responses carry no etag and no retry-after, and your code needs a plan for that. It should not crash on it.
This clip reads the same response, one header at a time.
Read the transcript
What an HTTP header is. A name and a value, sent with every request and response.
A header is a name, a colon and a value. Names match in any letter case. The request reads: GET /headers. Host: httpbin.org. The response reads: 200 OK. content-type: application/json. content-type is read: what the body is. JSON: the format to parse the body as.
Six response headers decide what a scraper does next. content-type: what the body is. cache-control: how long a copy stays fresh. etag: a label for this version. last-modified: a date for this version. retry-after: how long to wait. location: the address to ask next.
This response sent 1 of the 6. The run printed the other 5 as null. 1 was sent: content-type. 5 were not sent, so the run printed null. 6: headers the run looked for. 200: the status that came with them.
An absent header is an answer too. The status says which kind. A header is absent: read the status beside it. 200: No retry-after is the normal case. 429: No retry-after: log that one. 304: No location: nothing to follow. This run: 200.
Read the full page. The page is at spider.cloud/learn/http-headers.
One fetch, header by header
To see both sides of one exchange, the run below fetches https://httpbin.org/headers, a public test page that answers with a copy of the request headers it received. The body shows what went out, and return_headers hands back what came in. That option is off unless you turn it on.
curl -s https://api.spider.cloud/scrape \
-H "Authorization: Bearer $SPIDER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://httpbin.org/headers", "request": "http", "return_format": "raw", "user_agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)", "return_headers": true}'It needs an API key in SPIDER_API_KEY. What comes back is a JSON array holding one object for each page. The page's text is in its content field and the response headers are in its headers field. We made this call once, at 02:00:46 UTC on 2026-11-21. It returned status 200 for https://httpbin.org/headers with an error of null.
These are five of the request headers the test page said it received, copied from content as they arrived. The client sent more, which are left out here.
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.9",
"Host": "httpbin.org",
"User-Agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)"User-Agent is the name we set in the request body, so the site saw the crawler name we chose. Host names the site. The three Accept headers say which formats, compressions and languages the client takes.
From the same response, we kept the six headers in the list above. The run marks a header the response did not carry as null.
content-type application/json
cache-control null
etag null
last-modified null
retry-after null
location nullOne of the six was there. content-type says the body is JSON, so a JSON parser is the right tool here, even though the request's Accept header asked for HTML first. The server decides what it sends, and content-type is where it says so.
Five came back null. The test page sent no cache-control, which means only that this field is absent. Another field, such as expires, could still set a freshness rule, so check for it before you choose a schedule. No etag and no last-modified means this response gives a conditional request nothing to send back. No retry-after is the normal case for a 200. The response held no location header, and that is all it shows: the output does not tell us whether a redirect happened on the way.
This is one fetch of one page. Another site will send a different set, and a busy one is likely to send many more than six. Reading the same six on every response is what makes the code work on all of them.
Do this, avoid this
Do this
- Look header names up without regard to letter case.
- Read content-type before you choose how to parse the body.
- Save etag and last-modified next to each page you keep, so the next request can be conditional.
- Wait the time retry-after gives you before the next request to that site.
- Remove Set-Cookie and Authorization values from any header log you keep, because they can hold personal data.
Avoid this
- Matching a header by its exact capitalisation.
- Parsing a body as JSON when content-type says it is HTML.
- Writing code that fails when etag, cache-control or retry-after is missing.
- Storing whole header sets from signed-in sessions, where cookies and tokens ride along.
Check one yourself
Paste the request above, change the url to a page that its robots.txt and its terms allow you to fetch, and look through the headers object for the six names. You will get every header the response carried, not six, and a header the response did not carry is simply not in the object. Our table above shows those as null because we kept six names on purpose. In your own output, a name you cannot find was not in that response, so your code should treat it as missing. Then read the status next to them: a 200 with no etag is a different case from a 429 with no retry-after, and the second one is the one to log.
For the full list of fields and their rules, the source is RFC 9110, and it is long, so search it for the header name you hold.