This article is reprinted from the WeChat public account "JS Daily Question", the author is Huihui. Please contact the JS Daily Question public account to reprint this article. 1. What isHTTP header fields refer to the message header part in the request and response messages of the Hypertext Transfer Protocol (HTTP) They define the parameters of an operation within a HTTP transaction. HTTP header fields can be defined as needed, so non-standard header fields may be found on web servers and browsers. The following is a request header for an HTTP request:
2. ClassificationCommon request fields are shown in the following table:
3. Usage scenariosBy coordinating the request header and response header, the following functions can be implemented in some scenarios: Negotiation Cache Negotiation cache is managed using two pairs of request and response headers: [Last-Modified, If-Modified-Since] and [ETag, If-None-Match] Last-Modified indicates the date when the local file was last modified. The browser will add If-Modified-Since (the value of Last-Modified returned last time) to the request header to ask the server whether the resource has been updated after that date. If so, the new resource will be sent back. Etag is like a fingerprint. Any change in the resource will cause the ETag to change, regardless of the last modification time. ETag can ensure that each resource is unique. The If-None-Match header will send the Etag returned last time to the server, asking whether the Etag of the resource has been updated. If there is a change, a new resource will be sent back. Forced caching does not require sending requests to the server. It determines whether the strong cache is hit based on the request headers expires and cache-control. The flowchart of mandatory caching and negotiated caching is as follows: Session State Cookies are small text files that are stored on the user's local terminal by some websites in order to identify the user. They are determined by the response header set-cookie. As a small text data that generally does not exceed 4KB, it consists of a name (Name), a value (Value) and several other optional attributes used to control the validity period, security, and scope of use of the cookie. Cookies are mainly used in the following three aspects: Session state management (such as user login status, shopping cart, game scores, or other information that needs to be recorded) Personalization settings (such as user-defined settings, themes, etc.) Browser behavior tracking (such as tracking and analyzing user behavior, etc. References https://zh.wikipedia.org/wiki/HTTP header fields https://github.com/amandakelake/blog/issues/41 |
<<: What is the difference between a free SSL certificate and a paid one?
Korean media cited data from the Ministry of Scie...
[[389262]] In the previous article, we took a dee...
Free Wi-Fi is an indispensable service during tra...
ZJI is the original well-known WordPress host Wei...
Regardless, in theory the latest version of the 5...
Enterprises need to develop an effective and adap...
[[430223]] Preface In the browser, if we want to ...
2021 is the first year of implementation of my co...
After a turbulent 2020, China's 5G network co...
[Shenzhen, China, July 30, 2020] Today, at the Cl...
[[401820]] This article is reprinted from the WeC...
With the continuous iteration of WiFi technology,...
It has been a long time since I shared informatio...