20190116 q:

What are the front-end caches? What are the scenarios? What’s the difference?

Reference answer

The front-end cache is divided into two parts:

  • HTTP cache
  • Browser cache

HTTP cache

  • Strong cache

Strong caching is mainly controlled by cache-Control and Expires fields in the response header

Cache-control;

Max-age Specifies the maximum validity period of the cache (unit: s) public Specifies that the response is cached and shared between multiple users. Private The response is only a private cache and cannot be shared between users. Indicates that resources are not cached. No-store Indicates that caching is prohibited

Expires to understand:

Cache expiration time, used to specify the expiration time of a resource, is a specific point in time on the server side and needs to be used in combination with last-Modified

Last-modified understanding

The last modification time of the server side file, which must be used together with cache-control, is a way to check whether the server side resource is updated

ETag understand

A hash string is generated by the server to identify the resource status based on the entity content. The browser passes this string back to the server to verify that the resource has been modified

  • Negotiation cache (304)

Negotiated caching means that when a strong caching mechanism detects a cache failure, server revalidation is required

Browser cache

  • Cookie
  • LocalStorage
  • SessionStorage
  • Service Worker

Cookie

Cookies are used to store user information and have a capacity of 4KB

LocalStorage

LocalStorage data is stored in the browser until the user clears the browser cache data. The capacity is 5MB

SessionStorage

The other properties of SessionStorage are the same as LocalStorage, except that they are cleared when the page is closed

Service Worker

In order to improve the user experience of Web app, it can realize a series of functions such as offline application message push, which can be regarded as a Javascript proxy script independent of browser, and can also provide basic functions in offline state. For security reasons, Service workers can only be used in HTTPS protocol

The issue of

How to implement a Call, Apply, and Bind? What are some of the most common methods of web security attacks? And how to prevent it

JS daily question

JS Question of the day can be regarded as a voice answer community to complete the question of the day in the form of voice within 60 seconds with fragmented time every day, and the group owner will push the reference answer of the day at 0 o ‘clock the next day

  • Note is not limited to completing the task of the day, but more to check and fill in the gaps, learning from other students in the group excellent answer ideas

Scan the QR code below to join the answer