precache.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. Copyright 2019 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import { getOrCreatePrecacheController } from './utils/getOrCreatePrecacheController.js';
  8. import './_version.js';
  9. /**
  10. * Adds items to the precache list, removing any duplicates and
  11. * stores the files in the
  12. * {@link workbox-core.cacheNames|"precache cache"} when the service
  13. * worker installs.
  14. *
  15. * This method can be called multiple times.
  16. *
  17. * Please note: This method **will not** serve any of the cached files for you.
  18. * It only precaches files. To respond to a network request you call
  19. * {@link workbox-precaching.addRoute}.
  20. *
  21. * If you have a single array of files to precache, you can just call
  22. * {@link workbox-precaching.precacheAndRoute}.
  23. *
  24. * @param {Array<Object|string>} [entries=[]] Array of entries to precache.
  25. *
  26. * @memberof workbox-precaching
  27. */
  28. function precache(entries) {
  29. const precacheController = getOrCreatePrecacheController();
  30. precacheController.precache(entries);
  31. }
  32. export { precache };