सामान्य HTTP हेडर

HTTP हेडर कुंजी-मूल्य जोड़े होते हैं जो हर अनुरोध व प्रतिक्रिया की शुरुआत में भेजे जाते हैं। इनमें सामग्री प्रकार, कैश नियम और प्रमाणीकरण जैसा मेटाडेटा होता है। वेब ट्रैफ़िक बनाते या डिबग करते समय सबसे आम हेडर पहचानने में यह शीट मदद करती है।

अपडेट:

हेडरदिशाउद्देश्य
HostrequestIdentifies the server's host and port (from the URL).
User-AgentrequestReports the client software (browser, OS, bot) making the request.
AcceptrequestLists the response media types (MIME) the client can handle.
AuthorizationrequestCarries credentials (token, Basic auth) to authenticate the client.
Content-Typerequest/responseStates the media type of the request or response body.
Content-Lengthrequest/responseGives the size in bytes of the request or response body.
CookierequestSends stored key/value pairs from a previous response back to the server.
Set-CookieresponseServer instructs the client to store a cookie for later requests.
Cache-Controlrequest/responseDirects caching behaviour: no-cache, max-age, private, etc.
ETagresponseOpaque identifier for a resource version, used for revalidation.
If-None-MatchrequestSends an ETag; server returns 304 if the resource is unchanged.
LocationresponsePoints the client to a new URL for redirects (3xx) or created resources.
Access-Control-Allow-OriginresponsePermits a browser to share a response across origins (CORS).
X-Forwarded-ForrequestRecords the client IP as seen through a proxy or load balancer.
RefererrequestIndicates the URL of the page that linked to the requested resource.

टिप्पणियाँ

सामान्य प्रश्न

अनुरोध और प्रतिक्रिया हेडर में क्या अंतर है?
अनुरोध हेडर क्लाइंट (ब्राउज़र या ऐप) द्वारा सर्वर को भेजे जाते हैं; प्रतिक्रिया हेडर सर्वर अपने जवाब के साथ लौटाता है। कुछ जैसे Content-Type दोनों तरफ आते हैं।
क्या HTTP हेडर के नाम में बड़े-छोटे अक्षर का फ़र्क होता है?
नहीं। विनिर्देश के अनुसार हेडर नाम case-sensitive नहीं होते, इसलिए Content-Type और content-type एक ही हैं। Title-Case केवल परंपरा है।
Host हेडर क्या करता है?
Host सर्वर को बताता है कि अनुरोध किस डोमेन के लिए है। HTTP/1.1 में यह अनिवार्य है और एक सर्वर को नाम से कई साइटें होस्ट करने देता है।
हेडर से कैश कैसे काम करता है?
Cache-Control तय करता है कि उत्तर कितनी देर कैश किया जा सकता है; ETag व If-None-Match से क्लाइंट पूछता है 'क्या बदला?' और बिना बदले हल्का 304 Not Modified मिलता है।