Cabeçalhos HTTP comuns

Os cabeçalhos HTTP são pares chave-valor enviados no início de cada requisição e resposta. Transportam metadados como tipo de conteúdo, regras de cache e autenticação. Use esta folha para reconhecer os cabeçalhos mais comuns ao construir ou depurar tráfego web.

Atualizado:

CabeçalhoDireçãoFinalidade
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.

Notas

Perguntas frequentes

Qual a diferença entre cabeçalho de requisição e de resposta?
Os de requisição são enviados pelo cliente (navegador ou app) ao servidor; os de resposta são devolvidos pelo servidor com sua resposta. Alguns, como Content-Type, aparecem nos dois lados.
Os cabeçalhos HTTP diferenciam maiúsculas?
Não. Pela especificação, nomes de cabeçalho não diferenciam maiúsculas, então Content-Type e content-type são iguais. O Title-Case é só convenção.
Para que serve o cabeçalho Host?
Host informa ao servidor qual domínio a requisição alvo. É obrigatório em HTTP/1.1 e permite que um servidor hospede vários sites por nome.
Como a cache funciona com cabeçalhos?
Cache-Control define por quanto tempo uma resposta pode ser cacheada; ETag e If-None-Match deixam o cliente perguntar 'mudou?' e receber um leve 304 Not Modified.