[Original] -by- Emperor Yan Jin tyrants strong resolve browser cache problem solution

Front-end programmer knows that your browser's cache can both reduce the burden on the server, but also to front-end personnel inconvenience in the preparation of the site.

 

Browser cache is divided into: strong cache and cache consultation


Cache Cache is not strong parallel relationship and consultation, negotiation is an enhanced cache buffer on the basis of a strong cache function. Today, the discussion here is strong browser's cache to bring solution to the problem.

 

Strong caching process:


The first request: the browser sends a request to the first server, the server will add in response header Expires and Cache-Control: max-age = 365000000, both requests one or two heads.
Then: After the browser receives the response, cached put together this resource response header and response.

The next time you request: browser calculated based on the value of these two requests heads of the current time the cache has expired, but if the contents of the cache response directly to the server without sending a request access to resources.

(Expires, whose value is the absolute expiration time in GMT format, for example, 2019 June 23 12:00:00 expired, so clients such time after this time, the cache will expire .Cache-Control : max-age = 365000000, the value max-age request header is a period of time, i.e., which stores the relative time, for each request, the browser will request by subtracting the first time the client time is greater than the relative time period is expired, the need to re-request the resource)

 

Why use the browser cache and strong? (I.e., cache benefits):

  • Cache reduces redundant data transmission, saves network costs

  • Cache ease the bottleneck of network problems

  • Cache reduces the demands on the original server

  • Cache reduces latency distance

 

 

Guess you like

Origin www.cnblogs.com/ppwjs/p/9484849.html