One, HTTP response header, and cache control related fields in the request header
Second page access caching process
Three or three kinds of refreshing actual actions
Iv. How to set up the cache
One, HTTP response header, and cache control related fields in the request header
After the browser initiates a request to the server, the server's response header typically contains the following cache-related fields:
1.Expires: Expiration time. (Fields in HTTP 1.0)
When the browser initiates the request, it checks to see if it exceeds this time and reads the information directly from the cache if it is not exceeded. However, if the browser time and the server time are inconsistent, there will be problems.
2.cache-control:max-age=6000 (MS)/no-cache/no-store/private/public (field of HTTP 1.1)
When setting both expires and max-age, use the Max-age
3.last-modified: Last modified time.
4.Etag: The entity tag of the requested variable. Its calculation is obtained from the server-side algorithm, with priority higher than last-modified.
The browser initiates a request to the server again, and the request header typically contains the following cache-related fields:
1.cache-control:max-age=0
2.if-modified-since: Compares the last-modified in the response header to the server and the last modification time of the requested resource
If the last modification time is greater than if-modified-since, the resource has changed, and the response to the entire resource returns 200, otherwise 304 is returned.
3.if-none-match: The ETag in the response header is sent to the server and the service side of the entity tag to compare
If the same, the resource is not changed to return 304, otherwise the entire resource returns 200.
(Etag/if-none-match priority is higher than last-modified/if-modified-since)
Second page access caching process
Three or three kinds of refreshing actual actions
1. Enter the URL and press ENTER: The browser discovers this resource in the cache and takes it directly from the cache.
2.F5: Even if there is a resource in the cache, the server will verify that the resource has changed.
3.ctrl+f5: First delete the resources in the cache, then go to the server to request the complete resource file.
Iv. How to set up the cache
1. Configure Apache or Ngix server (not quite aware of this way)
2. Dynamically set in the server response header
3. Set in the META tag of the front-end HTML page (this method is not supported by all browsers, and the proxy server does not support this method because the proxy server does not parse the HTML page)
<meta http-equiv= "Cache-control" content= "max-age=600000"/>
<meta http-equiv= "Expires" content= "..."/>
4. set the request header with the setRequestHeader () method in the request, you can set not to use the cache or change the corresponding fields (such as setting if-none-modified, etc.)
(This article for the individual to the cache control some carding, welcome everybody to exchange the study ~)
HTTP Cache Control Summary