6月征文

81 阅读1分钟

Workbox模块:

  • workbox-routing: When the service worker intercepts requests this module routes those requests to different functions that provide responses; it's an implementation of the fetch event handler as mentioned in the Serving chapter.
  • workbox-strategies: A set of runtime caching strategies that handle responding to a request, such as cache first and stale while revalidate; it's an implementation of the different strategies mentioned in the Serving chapter.
  • workbox-precaching: It's an implementation of caching files in the install event handler of the service worker (also known as precaching), as mentioned in the Caching chapter. With this module you can easily precache a set of files and efficiently manage updates to those assets. We'll cover updating assets in the Update chapter.
  • workbox-expiration: It is a plugin used with the caching strategies to remove cached requests based on the number of items in a cache or based on the age of the cached request. It helps manage your caches and sets limits on time and the number of items in each cache.
  • workbox-window: A set of modules intended to run in the window context, which is to say, inside of your PWA web pages. You can simplify the process of service worker registration and updates and enable easier communication between code running in the service worker context and the window context.