Veelgebruikte HTTP-headers

HTTP-headers zijn sleutel-waardeparen die aan het begin van elk verzoek en antwoord worden meegestuurd. Ze dragen metadata zoals contenttype, cacheregels en authenticatie. Gebruik dit blad om de meest voorkomende headers te herkennen bij het bouwen of debuggen van webverkeer.

Bijgewerkt:

HeaderRichtingDoel
HostrequestIdentifies the server's host and port (from the URL).
User-AgentrequestReports the client software (browser, OS, bot) making the request.
AcceptrequestLists the response media types (MIME) the client can handle.
AuthorizationrequestCarries credentials (token, Basic auth) to authenticate the client.
Content-Typerequest/responseStates the media type of the request or response body.
Content-Lengthrequest/responseGives the size in bytes of the request or response body.
CookierequestSends stored key/value pairs from a previous response back to the server.
Set-CookieresponseServer instructs the client to store a cookie for later requests.
Cache-Controlrequest/responseDirects caching behaviour: no-cache, max-age, private, etc.
ETagresponseOpaque identifier for a resource version, used for revalidation.
If-None-MatchrequestSends an ETag; server returns 304 if the resource is unchanged.
LocationresponsePoints the client to a new URL for redirects (3xx) or created resources.
Access-Control-Allow-OriginresponsePermits a browser to share a response across origins (CORS).
X-Forwarded-ForrequestRecords the client IP as seen through a proxy or load balancer.
RefererrequestIndicates the URL of the page that linked to the requested resource.

Opmerkingen

Veelgestelde vragen

Wat is het verschil tussen een request- en een response-header?
Request-headers worden door de client (browser of app) naar de server gestuurd; response-headers komen van de server met het antwoord. Sommige, zoals Content-Type, komen aan beide kanten voor.
Zijn HTTP-headernamen hoofdlettergevoelig?
Nee. Volgens de specificatie maken headernamen geen onderscheid in hoofdletters, dus Content-Type en content-type zijn hetzelfde. Title-Case is slechts een conventie.
Wat doet de Host-header?
Host vertelt de server welk domein de aanvraag bedoelt. In HTTP/1.1 verplicht en laat één server veel sites op naam hosten.
Hoe werkt caching met headers?
Cache-Control bepaalt hoe lang een antwoord gecached mag worden; ETag en If-None-Match laten de client vragen 'veranderd?' en goedkoop 304 Not Modified ontvangen.