Entity headers are HTTP headers that provide information about the body of a message. They can appear in both requests and responses, describing properties of the content such as type, length, encoding, or last modification date.
1.
Content-Type
Content-Type: application/json; charset=UTF-8
2.
Content-Length
Content-Length: 1024
3.
Content-Encoding
Content-Encoding: gzip
4. Content-Language
Content-Language: de-DE
5. Cache-Location
Content-Location: /files/document.pdf
6. Last-Modified
Last-Modified: Tue, 30 Jan 2025 14:20:00 GMT
7. ETag
ETag: "abc123xyz"
8. Expires
Expires: Fri, 02 Feb 2025 12:00:00 GMT
9. Allow
Allow: GET, POST, HEAD
10. Refresh
(Not standardized but often used)
Refresh: 10; url=https://example.com
These headers help describe the content of an HTTP message, optimize caching strategies, and ensure correct rendering.
Response headers are HTTP headers sent from the server to the client. They contain information about the server’s response, such as status codes, content types, security policies, or caching rules.
1. Server
Server: Apache/2.4.41 (Ubuntu)
2. Date
Date: Wed, 31 Jan 2025 12:34:56 GMT
3. Content-Type
Content-Type: text/html; charset=UTF-8
4. Content-Length
Content-Length: 3456
5. Cache-Control
Cache-Control: max-age=3600, must-revalidate
6. Set-Cookie
Set-Cookie: sessionId=abc123; Path=/; Secure; HttpOnly
7. ETag
ETag: "5d8c72a5f8d9f"
8. Location
Location: https://www.new-url.com/
9. Access-Control-Allow-Origin
Access-Control-Allow-Origin: *
10. Strict-Transport-Security
(HSTS)
Strict-Transport-Security: max-age=31536000; includeSubDomains
Response headers help the client interpret the received response correctly, enforce security measures, and optimize caching strategies.
Request headers are HTTP headers sent by a client (e.g., a web browser or API request) to the server, providing additional information about the request, the client, or the desired content.
1. Host
Host: www.example.com
2. User-Agent
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
3. Accept
Accept: text/html, application/json
4. Accept-Language
Accept-Language: de-DE, en-US
5. Accept-Encoding
Accept-Encoding: gzip, deflate, br
6. Referer
Referer: https://www.google.com/
7. Authorization
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
8. Cookie
Cookie: sessionId=abc123; theme=dark
9. Content-Type
(for POST/PUT-Anfragen)
Content-Type: application/json
10. Origin
Origin: https://www.example.com
These headers help the server understand the request and respond accordingly by providing details about the client, preferred content, and security aspects.
General HTTP headers are headers that can be used in both HTTP requests and responses. They contain general information about the connection and data transfer that is not specific to the client, server, or content.
1. Cache-Control
Cache-Control: no-cache, no-store, must-revalidate
2. Connection
Connection: keep-alive
3. Date
Date: Wed, 31 Jan 2025 12:34:56 GMT
4. Pragma
(veraltet, aber noch genutzt)
Cache-Control
, mainly used for backward-compatible caching rules.für rückwärtskompatible Caching-Regeln genutzt.Pragma: no-cache
5. Trailer
Trailer: Expires
6. Transfer-Encoding
Transfer-Encoding: chunked
7. Upgrade
Upgrade: websocket
8. Via
Via: 1.1 proxy.example.com
These headers improve communication between the client and server, manage caching, and allow protocol upgrades.
HTTP headers are metadata exchanged between the client (e.g., a browser) and the server during HTTP requests and responses. They contain important information for communication, such as:
Cache-Control
for caching rules).User-Agent
, which identifies the browser type).Server
, which indicates the web server used).Content-Type
, which specifies the media type of the response).Example of an HTTP request with headers:
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html
Example of an HTTP response with headers:
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 3456
Server: Apache
HTTP headers are commonly used for security (e.g., Strict-Transport-Security
), performance optimization (e.g., Cache-Control
), and authentication (e.g., Authorization
).