bg_image
header

Response Headers

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.

Important Response Headers:

1. Server

  • Indicates which software or technology the server is using.
  • Example:
Server: Apache/2.4.41 (Ubuntu)

2. Date

  • Specifies the date and time of the server’s response in GMT format.
  • Example:
Date: Wed, 31 Jan 2025 12:34:56 GMT

3. Content-Type

  • Defines the media type of the response.
  • Example:
Content-Type: text/html; charset=UTF-8

4. Content-Length

  • Indicates the size of the response in bytes.
  • Example:
Content-Length: 3456

5. Cache-Control

  • Determines the caching behavior of the response.
  • Example:
Cache-Control: max-age=3600, must-revalidate

6. Set-Cookie

  • Sends cookies to the client for storage and future requests.
  • Example:
Set-Cookie: sessionId=abc123; Path=/; Secure; HttpOnly

7. ETag

  • A unique identifier for a specific version of a resource, used for caching optimization.
  • Example:
ETag: "5d8c72a5f8d9f"

8. Location

  • Specifies a redirect URL if a resource has moved.
  • Example:
Location: https://www.new-url.com/

9. Access-Control-Allow-Origin

  • Enables cross-origin requests (CORS).
  • Example:
Access-Control-Allow-Origin: *

10. Strict-Transport-Security (HSTS)

  • Enforces HTTPS for future requests.
  • Example:
Strict-Transport-Security: max-age=31536000; includeSubDomains

Response headers help the client interpret the received response correctly, enforce security measures, and optimize caching strategies.


HTTP Request headers

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.

Important Request Headers:

1. Host

  • Specifies the target domain or IP address of the server.
  • Example:
Host: www.example.com

2. User-Agent

  • Contains information about the client, such as browser type or operating system.
  • Example:
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)

3. Accept

  • Defines which content types the client can accept.
  • Example:
Accept: text/html, application/json

4. Accept-Language

  • Specifies the client's preferred language(s).
  • Example:
Accept-Language: de-DE, en-US

5. Accept-Encoding

  • Indicates which compression formats the client supports.
  • Example:
Accept-Encoding: gzip, deflate, br

6. Referer

  • Provides the previous page from which the user navigated.
  • Example:
Referer: https://www.google.com/

7. Authorization

  • Used for authentication when accessing protected resources.
  • Example(Basic Auth):
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

8. Cookie

  • Contains cookies previously set by the server.
  • Example:
Cookie: sessionId=abc123; theme=dark

9. Content-Type (for POST/PUT-Anfragen)

  • Specifies the data format of the request body.
  • Example:
Content-Type: application/json

10. Origin

  • Indicates the origin URL and is often used in Cross-Origin requests.
  • Example:
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.