List of important HTTP request headers
📋 Complete Standard HTTP Request Headers
- A-IM - Acceptable instance-manipulations for the resource, used for delta encoding
- Accept - Media types the client can process (JSON, HTML, etc.)
- Accept-Charset - Character sets the client supports (UTF-8, ISO-8859-1)
- Accept-Encoding - Compression algorithms client accepts (gzip, deflate, br)
- Accept-Language - Preferred natural languages for response (en-US, fr-CA)
- Accept-Datetime - Request past version before specific datetime
- Access-Control-Request-Method - Method to use in actual CORS request
- Access-Control-Request-Headers - Headers to use in actual CORS request
- Authorization - Authentication credentials for HTTP auth
- Cache-Control - Directives for caching mechanisms
- Connection - Controls connection persistence (keep-alive, close)
- Content-Length - Size of request body in decimal bytes
- Content-Type - Media type of request body (POST/PUT only)
- Cookie - Previously stored HTTP cookies from server
- Date - Date and time when request was originated
- Expect - Expectations server must fulfill (100-continue)
- Forwarded - Proxy/client original connection information
- From - Email address of human user controlling agent
- Host - Server domain and port (REQUIRED in HTTP/1.1)
- If-Match - Only proceed if ETag matches (prevents lost updates)
- If-Modified-Since - Return 304 if unchanged since date (saves bandwidth)
- If-None-Match - Return 304 if ETag matches (caching optimization)
- If-Range - Resume downloads if ETag/date matches, full resource if not
- If-Unmodified-Since - Only proceed if resource not modified since date
- Max-Forwards - Limit proxy/gateway forwarding (TRACE/OPTIONS)
- Origin - Cross-origin request source (triggers CORS)
- Pragma - Implementation-specific directives (legacy: no-cache)
- Proxy-Authorization - Credentials for proxy authentication
- Range - Request only specific byte range of resource
- Referer - Previous page address that linked to current request
- TE - Acceptable transfer encodings (trailers, gzip)
- User-Agent - Client application identification string
- Upgrade - Request to switch to different protocol
- Via - Intermediate proxies traversed by request
- Warning - General warning about message status
🔧 Non-Standard & Custom Headers
- DNT - Do Not Track preference signal (1 = do not track)
- X-Requested-With - Identifies AJAX requests (XMLHttpRequest)
- X-CSRF-Token - Anti-CSRF protection token validation
- X-Forwarded-For - Client original IP through proxies (de facto standard)
- X-Forwarded-Proto - Original protocol (http/https) through proxies
- X-Forwarded-Host - Original host through load balancers
🛡️ Important Security Headers to Know
- Authorization & Cookie handle authentication and sessions
- Origin & CORS headers manage cross-origin security
- X-CSRF-Token prevents Cross-Site Request Forgery attacks
- Content-Type validation prevents MIME-type attacks
⚡ Quick Usage Guide
- For APIs: Use
Accept: application/json,Content-Type: application/json,Authorization: Bearer <token> - For Browsers: Automatically includes
User-Agent,Accept,Accept-Encoding,Accept-Language,Cookie,Referer - For CORS: Browser sends
Origin, preflight usesAccess-Control-Request-MethodandAccess-Control-Request-Headers - For Performance: Use
Accept-Encoding: gzip, cache headers,If-Modified-Since, andIf-None-Match
🎯 Key Takeaways
- Host header is mandatory in HTTP/1.1 requests
- Content-Type required when sending data in request body
- Security headers like Authorization and X-CSRF-Token protect your application
- Performance headers like Accept-Encoding and cache controls improve speed
- CORS headers enable secure cross-origin API access
- Most headers are optional but using appropriate ones improves functionality

