HTTP headers are key-value pairs that accompany HTTP requests and responses to provide metadata about the communication. They define how the client and server should interact, such as content type, caching instructions, and authentication details.
Common HTTP Headers
General Headers
- Cache-Control: Specifies caching mechanisms (e.g.,
no-cache
,max-age
). - Connection: Indicates connection options (e.g.,
keep-alive
,close
). - Date: Represents the date and time the message was sent.
Request Headers
- Accept: Lists the media types the client can receive.
- User-Agent: Identifies the client's software (e.g., browser, OS).
- Authorization: Contains credentials for HTTP authentication.
Response Headers
- Content-Type: Defines the media type of the resource (e.g.,
text/html
,application/json
). - Location: Specifies the URL of the resource after redirection.
- Server: Indicates the server software (e.g.,
Apache/2.4
).
Example Usage
For a GET request to /en/technical/reference/http-headers
, the server might respond with headers like:
HTTP/1.1 200 OK
Content-Type: text/html
Cache-Control: public, max-age=3600
Extend Your Knowledge
Explore more about HTTP methods and their relationship with headers.