Types of HTTP Headers and Their Functions
Types of HTTP Headers

Types of HTTP Headers and Their Functions

HTTP headers are key-value pairs sent between a client (browser) and a server during an HTTP request or response. They help in communication, security, caching, and content handling.


1️⃣ Request Headers (Sent by the Client)

These headers are sent by the browser or client when making an HTTP request to the server.

1.1 General Request Headers

🔹 Host: Specifies the domain name of the server.

http        


Host: www.example.com

🔹 User-Agent: Provides information about the client (browser, OS, device).

h        


User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)

🔹 Referer: Tells the server the previous URL from where the request originated.

http        


Referer: https://google.com

🔹 Accept: Specifies the media types the client can handle.

h        


Accept: text/html, application/json

🔹 Accept-Language: Defines the preferred languages.

http        


Accept-Language: en-US, en;q=0.9

🔹 Accept-Encoding: Specifies the encoding formats the client supports.

h        


Accept-Encoding: gzip, deflate, br

🔹 Authorization: Sends authentication credentials (e.g., API keys, JWT).

http        


Authorization: Bearer <token>


1.2 Conditional Request Headers

These headers allow caching and efficient data retrieval.

🔹 If-Modified-Since: Fetches data only if modified after a given date.

h        


If-Modified-Since: Mon, 01 Jan 2024 12:00:00 GMT

🔹 If-None-Match: Fetches data only if the ETag doesn’t match.

http        


If-None-Match: "etag12345"


2️⃣ Response Headers (Sent by the Server)

These headers are sent by the server in response to the client’s request.

2.1 General Response Headers

🔹 Server: Provides information about the server software.

http        


Server: Apache/2.4.41 (Ubuntu)

🔹 Date: Specifies the response date and time.

http        


Date: Wed, 21 Feb 2025 12:34:56 GMT

🔹 Connection: Controls whether the connection stays open.

http        


Connection: keep-alive


2.2 Content Headers

🔹 Content-Type: Specifies the type of content being sent.

h        


Content-Type: text/html; charset=UTF-8

🔹 Content-Length: Defines the size of the response body in bytes.

http        


Content-Length: 5120

🔹 Content-Encoding: Specifies compression applied to the response.

h        



2.3 Caching Headers

🔹 Cache-Control: Controls caching behavior.

http        


Cache-Control: max-age=3600, public

🔹 Expires: Defines when the content should expire.

h        


Expires: Thu, 01 Mar 2025 12:00:00 GMT

🔹 ETag: Unique identifier for cached resources.

http        



2.4 Security Headers

🔹 Strict-Transport-Security (HSTS): Forces HTTPS connections.

http        


Strict-Transport-Security: max-age=31536000; includeSubDomains

🔹 Content-Security-Policy (CSP): Prevents cross-site scripting (XSS).

http        


Content-Security-Policy: default-src 'self'

🔹 X-Frame-Options: Prevents clickjacking attacks.

http        


X-Frame-Options: DENY

🔹 X-XSS-Protection: Protects against cross-site scripting attacks.

http        


X-XSS-Protection: 1; mode=block

🔹 X-Content-Type-Options: Prevents MIME-type sniffing.

http        


X-Content-Type-Options: nosniff


2.5 Redirect Headers

🔹 Location: Redirects the client to another URL.

http        


Location: https://www.newsite.com

🔹 Refresh: Auto-refreshes or redirects after a specific time.

http        


Refresh: 5; URL=https://example.com


3️⃣ Entity Headers (Metadata About the Resource)

🔹 Last-Modified: Indicates when the resource was last changed.

http        


Last-Modified: Tue, 20 Feb 2025 15:00:00 GMT

🔹 Allow: Lists allowed HTTP methods.

http        

Conclusion

HTTP headers are essential for communication between clients and servers. They control caching, security, content types, and user authentication, making web applications more efficient and secure. 🚀

To view or add a comment, sign in

More articles by Mukesh Kumar Pareek

  • llms.txt – The New Frontier of SEO in the Age of AI

    As search evolves beyond traditional engines into AI-powered answers, a new standard is quietly emerging — llms.txt.

  • (GEO)- Generative Engine Optimization ?

    Discover the role of GEO, its influence on digital marketing, and smart strategies to leverage AI search ! Generative…

    2 Comments
  • Enable Google Tag Gateway in GTM

    To enable the Google Tag Gateway for advertisers, which allows you to serve Google tags (like Google Analytics and…

    3 Comments
  • 🔍 How to See AI Overview Traffic

    Right now, Google does not show a separate traffic source labeled "AI Overview" directly in Google Analytics or Google…

    3 Comments
  • Marketing Funnel and Meta Ad Funnel

    In this document, we will explore the concepts of the marketing funnel and the Meta ad funnel, highlighting their…

    1 Comment
  • Major Disadvantages and Lost Opportunities of Blocking AI Crawlers on Your Website :

    Blocking AI crawlers from accessing your website can offer control and privacy, but it also comes with some trade-offs.…

    1 Comment
  • LinkedIn Ads Eo-System: A Comprehensive Guide

    LinkedIn Ads is a powerful advertising platform that allows businesses to reach a professional audience. It offers…

    1 Comment
  • Google Ads Eco-System

    🧱 1. Campaign This is the top-level structure in Google Ads.

    1 Comment
  • Types of Meta Tags and Their Uses

    Meta tags are snippets of HTML code that provide information about a webpage to search engines and website visitors…

  • Visible URL Element on Mobile - SEO Update

    In January 2025, Google updated its mobile search results to enhance user experience on smaller screens. Previously…

Others also viewed

Explore content categories