Ctrl + K
HTTP8 min read

HTTP Headers Reference

Explore the most commonly used HTTP headers, understand what they do and learn when to use them in web applications, APIs and browsers.

Published: 2026-08-07

HTTP headers are metadata exchanged between clients and servers during every HTTP request and response. They provide additional information about the message, such as the content type, authentication details, caching instructions, compression methods and browser capabilities. Without headers, modern web applications and APIs would not function efficiently or securely.

Although hundreds of standardized and custom HTTP headers exist, developers typically work with a relatively small set of frequently used headers. Understanding their purpose makes it much easier to build APIs, troubleshoot networking problems and optimize website performance.

What Are HTTP Headers?

HTTP headers are key-value pairs included before the message body in HTTP requests and responses. Each header provides specific information that helps clients and servers communicate correctly without affecting the actual content being transferred.

Where Headers Appear

MessageContains Headers
HTTP RequestYes
HTTP ResponseYes

Request Headers vs Response Headers

Some headers are sent by clients to describe the request, while others are returned by servers to describe the response. Certain headers may appear in both directions depending on the communication scenario.

Header TypePurpose
Request headersDescribe client capabilities and request details
Response headersDescribe the returned resource and server behavior
General headersApply to both requests and responses

HTTP Header Format

Each HTTP header consists of a name followed by a colon and a value. Multiple headers are sent together before the message body.

Content-Type: application/json

Most Common Request Headers

HeaderPurpose
HostIdentifies the destination host
User-AgentIdentifies the client application
AcceptSpecifies acceptable response formats
AuthorizationProvides authentication credentials
Content-TypeDescribes the request body
OriginIdentifies the requesting origin
RefererIndicates the previous page
CookieSends stored cookies

Most Common Response Headers

HeaderPurpose
Content-TypeDescribes the response body
Content-LengthSpecifies response size
Cache-ControlControls caching behavior
Set-CookieCreates or updates cookies
LocationProvides redirect destination
ETagSupports cache validation
Access-Control-Allow-OriginControls CORS access
Content-EncodingSpecifies compression

General Headers

Some headers are not limited to requests or responses. These general headers describe aspects of the HTTP message itself and may appear in both directions depending on the protocol version and implementation.

HeaderCommon Usage
DateTimestamp
ConnectionConnection management
Transfer-EncodingMessage transfer method
ViaProxy information
💡 When debugging APIs, examining HTTP headers often reveals the root cause much faster than inspecting the response body alone.
⚠️ Header names are standardized. Misspelled or incorrectly formatted headers may be ignored entirely by browsers, servers or proxies.

Content Negotiation Headers

Content negotiation allows clients and servers to agree on the best representation of a resource. Browsers and API clients send preference headers, while servers return content matching those preferences whenever possible.

HeaderPurpose
AcceptPreferred response media types
Accept-EncodingSupported compression algorithms
Accept-LanguagePreferred languages
Accept-CharsetPreferred character encodings

Authentication Headers

Authentication headers help identify users or applications. REST APIs commonly use bearer tokens, while some enterprise systems continue to use Basic authentication or custom authorization schemes.

HeaderTypical Usage
AuthorizationBearer tokens, Basic authentication
WWW-AuthenticateAuthentication challenge
Proxy-AuthorizationProxy authentication
Authorization: Bearer eyJhbGciOi...

Caching Headers

Caching headers reduce unnecessary network requests by allowing browsers, CDNs and proxies to reuse previously downloaded resources. Proper cache configuration improves performance while reducing server load.

HeaderPurpose
Cache-ControlCaching directives
ETagCache validation identifier
If-None-MatchConditional request using ETag
Last-ModifiedResource modification date
If-Modified-SinceConditional request by date
ExpiresCache expiration time

Compression Headers

Modern web servers compress responses before sending them to clients. Compression headers indicate which algorithms are supported and which algorithm was actually used for the response.

HeaderPurpose
Accept-EncodingSupported compression
Content-EncodingApplied compression

CORS Headers

Cross-Origin Resource Sharing (CORS) headers determine whether browsers allow JavaScript running on one origin to access resources hosted on another origin. These headers are essential for modern APIs consumed by web applications.

HeaderPurpose
Access-Control-Allow-OriginAllowed origins
Access-Control-Allow-MethodsAllowed HTTP methods
Access-Control-Allow-HeadersAllowed request headers
Access-Control-Allow-CredentialsCredential support
Access-Control-Max-AgePreflight cache duration

Cookie Headers

Cookies are transferred using dedicated HTTP headers. Browsers send stored cookies to servers using the Cookie header, while servers create or update cookies through the Set-Cookie response header.

HeaderDirection
CookieRequest
Set-CookieResponse

Security Headers

Security headers help browsers defend against common web attacks including clickjacking, MIME sniffing and cross-site scripting. Properly configuring these headers is an important part of securing modern web applications.

HeaderPurpose
Content-Security-PolicyRestricts resource loading
Strict-Transport-SecurityForces HTTPS
X-Content-Type-OptionsDisables MIME sniffing
X-Frame-OptionsPrevents clickjacking
Referrer-PolicyControls referrer information
Permissions-PolicyRestricts browser features
💡 Learning a few dozen commonly used headers is usually enough for day-to-day API development. You can look up less common headers only when you encounter them.
⚠️ Some headers affect browser behavior significantly. Accidentally misconfiguring caching, CORS or security headers can cause difficult-to-diagnose application issues.

HTTP/2 and HTTP/3 Headers

Although HTTP/2 and HTTP/3 significantly changed how HTTP messages are transmitted, the concept of headers remains the same. Modern protocol versions compress headers more efficiently and transmit them in binary form internally, reducing bandwidth usage and improving performance while preserving the familiar header names developers already know.

Custom HTTP Headers

Applications can define their own HTTP headers to exchange additional metadata. Custom headers are commonly used for request tracing, API versioning, feature flags, client identification and internal debugging. Choosing descriptive names helps keep APIs consistent and easier to maintain.

Example HeaderTypical Purpose
X-Request-IDRequest tracing
X-Correlation-IDDistributed logging
API-VersionAPI version selection
X-Client-VersionApplication version
Idempotency-KeyPrevent duplicate operations

Inspecting HTTP Headers

Developers inspect HTTP headers regularly when debugging APIs, troubleshooting browser issues or optimizing performance. Browser Developer Tools, command-line utilities and API clients all display request and response headers, making it possible to verify authentication, caching, compression and CORS configuration.

Common Header Mistakes

  • Returning an incorrect Content-Type.
  • Forgetting Cache-Control on cacheable resources.
  • Sending overly permissive CORS headers.
  • Including sensitive information in custom headers.
  • Using deprecated security headers instead of modern alternatives.
  • Assuming header names are translated or localized.

Best Practices

  • Return only headers that are actually needed.
  • Use standardized header names whenever possible.
  • Configure appropriate caching policies.
  • Secure applications with modern HTTP security headers.
  • Verify request and response headers during API testing.
  • Document custom headers used by your API.
💡 When an API behaves unexpectedly, compare the complete request and response headers before investigating application code. Header differences often reveal authentication, caching or CORS problems immediately.
⚠️ Never expose secrets, passwords or private tokens through HTTP headers that could be logged by proxies, browsers or monitoring systems.

Frequently Asked Questions

What are HTTP headers?

HTTP headers are key-value pairs exchanged between clients and servers that provide metadata about requests and responses, such as content type, authentication, caching and security policies.

What's the difference between request and response headers?

Request headers are sent by the client to describe the request, while response headers are returned by the server to describe the resource and how it should be handled.

Can applications define custom HTTP headers?

Yes. APIs frequently use custom headers for request tracking, versioning, diagnostics and other application-specific purposes, although standardized headers should be preferred whenever possible.

Which HTTP headers are most important for APIs?

Common API headers include Authorization, Content-Type, Accept, Cache-Control, ETag, Access-Control-Allow-Origin and various authentication or versioning headers depending on the API design.

How can I inspect HTTP headers?

You can inspect them using browser Developer Tools, API testing tools, command-line clients such as curl or server-side logging during request processing.

Helpful HTTP Tools

An HTTP Header Viewer lets you inspect complete request and response headers, an HTTP Header Generator helps build correctly formatted headers for testing, an HTTP Headers Parser converts raw header blocks into structured output, an HTTP Request Builder simplifies creating custom requests with specific headers, and an HTTP Response Formatter makes server responses easier to analyze while verifying returned header values.

Conclusion

HTTP headers are the foundation of communication between browsers, servers and APIs. They control everything from content negotiation and authentication to caching, compression, cookies, security and cross-origin access. While there are many standardized headers, understanding the most commonly used ones is enough for the majority of web development tasks. Keeping a reliable HTTP headers reference nearby makes debugging faster, simplifies API development and helps ensure applications remain secure, performant and standards-compliant.