Skip to content

precache ​

Function @vite-pwa/workbox-swkit/precaching
ts
precache(entries?: string | PrecacheEntry[], options?: PrecacheOptions): void

Adds items to the precache list, removing any duplicates and stores the files in the workbox-core.cacheNames|"precache cache" when the service worker installs.

This method can be called multiple times.

Please note: This method will not serve any of the cached files for you. It only precaches files. To respond to a network request you call workbox-precaching.addRoute.

If you have a single array of files to precache, you can just call workbox-precaching.precacheAndRoute.

Parameters ​

  • entries – Array of entries to precache.

  • options – Configurations for downloading the precache entries in parallel. Invalid concurrency values are ignored and fall back to 5.

Released under the MIT License.