Wednesday, July 10, 2024

HTTP Headers


HTTP Request and Response objects consist of a body and header. While the body in the Response holds the data message (HTML, JSON) or form fields in the Request, the headers let the client and the server pass essential information about each other.
Headers can be grouped into four categories by their context:
  • General headers contain information that is relevant for both request and Response, but no information about the data in a body.
  • Request headers hold information about the client and requested resources.
  • Response headers include server details, like time, location, and configuration.
  • Entity header informs the browser about the type and body of the resource.
Let’s inspect more in detail. Go to the webpage https://madurai.nic.in/, open the console > Network tab, and select the document to inspect headers. You will likely see the headers divided into General, Request, and Response.

General group consist of the following information:
Request Headers include the following properties:
  • Accept: / (Accept any content type)
  • Accept-Encoding: gzip, deflate, br, zstd (An algorithm, such as compression that is used on the recourse sent back.)
  • Accept-Language: en-US, en (Hints the server about the expected language)
  • Connection: keep-alive (Controls how long connection should stay open)
  • User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 (Lets server to identify the characteristics of the application, OS, vendor, and versions)
Response Headers include:
  • Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 (Set the instruction for caching. Other setting types: no-cache, no-store, no-transform)
  • Content-Encoding: Specifies the compression algorithm used for the response body
  • Content-Length: 17 (The size of the recourse in bytes)
  • Content-Type: application/json; charset=UTF-8 (The resource type received. The current type is a JSON document.)
  • Date: Tue, 09 Jul 2024 06:57:27 GMT (The time when the message was created)
  • Expires: Wed, 11 Jan 1984 05:00:00 GMT (Sets the date when the relevant content will no longer be new/fresh)
  • Server: Specifies the software used by the server at the time of the sent Response

No comments:

Post a Comment