The browser cache and the server agree on a set of rules:

  • In a session, check whether the copy is up to date.
  • The browser creates a space on the hard disk to store a copy of the resource as a cache.
  • Caching works when the user clicks back/Visited Link/image.
  • The client requests data from the server. The server finds that the file has not changed and sends 304-Not Modified to the client. The client receives the file and uses the cache file.
  • An e-tag can uniquely identify a file, and the client can ask the server if the file has changed:
A. If the e-tag of the file is valid, the server returns the 304-not Modified + e-tag of the file, and the browser uses the cache. B. If not, return 200-OK+ new resource.Copy the code

Cache detection process:

  • Cache-control /expires specifies the expiration date of a resource and controls whether the browser can cache or re-request data to the server. Cache-control has a higher priority than Expires.
  • After requesting the server, Last Modified /ETag is processed based on whether the return code is 304 or 200
  • Users can disable caching by adding CONTNT=”no cache” to the META tag in HTML

Proxy server: The reverse proxy and the user are on the same network. The reverse proxy cache, also known as edge cache, is used to provide static content and reduce server involvement. Edge cache such as CDN.