Browser's cache can greatly improve the performance of pages, and improve the user experience.
When the browser first enter a URL to access the server, the server sends a resource, and a band the ETag (current unique identifier of the resource), and the Last-Modified (last modified time to mark the current resource) to the browser request resources to cache when the browser requests a second time, according to the browser's caching mechanism to judge whether the cache expires, if not expired, the direct use of cache resources, such as expired re-request resources from the server.
1.1 browser cache control
1.1.1 can set meta tags, set the current page is not cached, every access need to pull the server
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
1.1.2 has a relationship with the cached HTTP message header
Cache-Control response information
Cache-Control there are many values, max-age To get the server request cache buffer before the effective time of the largest no-cache, whether the resource is the latest no-store
Disable caching
Expries used to specify an expiration time of resources, lower priority than the Cache-Control
Last-modified & If-modified-since
When the browser request again, it will bring in the request information I previously f-modified-since inquiry Last-modified point in time, whether the resource has been modified, if not modified return 304, use the cache, if modified, then again resource request to the server, return code 200
Etag 和 If-None-Match
The server generates some hash string to mark the resources to carry browser request header If-None-Match Etag check whether there are changes, compared with Last-modified more accurate, the server will give priority to contrast Etag
1.1.2 The following units will not request the browser cache
- The HTTP header Cache-Control: no-cache or Cache-Control: max-age = 0
- Dynamic request to enter the content based on cookie, authentication information decision
- post request can not be cached
- After https encrypted cache
http response header does not contain the Last-modified & If-modified- since Etag and If-None-Match can not be cached
The impact of user behavior on the cache, F5 strong cache invalidation, ctrl + F5 cache fail, need to re-request