Generally only the get type request is cached, the post is not cached
Cache negotiation
Refers to the negotiation between the browser and the Web server for whether to use browser-side caching. For smaller file content, the throughput rate is not increased because the cache negotiation still requires a request to be sent, but there is no body transfer, which saves server bandwidth
1.last-modified/if-modified-since/304 Absolute Time
The Web server adds last-modified to the response header, indicating when the content was last updated. When the browser requests again, If-modified-since is added to the request header. The Web server checks whether the content is updated after this time, and if there is an update (regardless of whether the content changes), returns the entire content. Otherwise, returns 304 without the body
For static content, the Web server obtains the last modification time of the file and compares it with the time the browser asks.
2.etag/if-none-match
If the etag of a content has not changed, then the contents of the file have not changed
Http1.1 does not specify the format and calculation method of the ETag, the Web server can be implemented by itself
The ETag is better for the following: The file is updated frequently but the content is constant; multiple Web services load balanced, and the last update time for files on each service is difficult
Complete elimination of requests
1.Expires Absolute Time
Browser does not need to request server every time before it expires
Web server is not turned on by default and needs to be opened manually
For common static file formats, even if the server does not return expires, the browser may decide to use the local cache at its own discretion
2. cache-control:max-age=3600
Specifies the relative time, in seconds, that the cache expires. Prevents local time and server time from being inconsistent.
Browsers generally use HTTP1.1 as the preferred option, and when both expires and Cache-control are available, priority is given to Cache-control
How to request a page
1. Ctrl+f5 Forced Refresh
Request the latest content directly from the Web service without using cache negotiation
2. F5 General Refresh
Allows the browser to do the necessary cache negotiation, but does not allow the use of local cache
3. Enter or click the hyperlink in the Address bar
This uses the most, allowing the browser to get the data with minimal requests
HTTP caching mechanism Grooming