Ruby HTTP request response - 3
HTTP request headers can be broadly divided into 3 parts -
- Response Headers
- Request Headers
Sample HTTP request format
"GET /blog HTTP/1.1"
Let’s divide it into sections and see what each one means
Tells about response formats that client can accept. e.g.
text/html, application/json, application/xml, text/css, image/*, */*
Allows client to specify from which URI this http request is generated/ requested. Like
It is of great help for analytics.
- User agent
Indicates which browser the request is sent from. like
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Used to indicate various flags in cache control mechanism. Like
- max-age - to indicate client accepts cached data whose age is not greater than value in seconds).
- public - server can use any cache to store data
- no-cache - cache must not use data for subsequent request without re-validation.
- no-store - server can not use cache the request or response.
- must-revalidate - revalidate stale data before using