getCacheKeyForURL.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. * Takes in a URL, and returns the corresponding URL that could be used to
  11. * lookup the entry in the precache.
  12. *
  13. * If a relative URL is provided, the location of the service worker file will
  14. * be used as the base.
  15. *
  16. * For precached entries without revision information, the cache key will be the
  17. * same as the original URL.
  18. *
  19. * For precached entries with revision information, the cache key will be the
  20. * original URL with the addition of a query parameter used for keeping track of
  21. * the revision info.
  22. *
  23. * @param {string} url The URL whose cache key to look up.
  24. * @return {string} The cache key that corresponds to that URL.
  25. *
  26. * @memberof module:workbox-precaching
  27. */
  28. function getCacheKeyForURL(url) {
  29. const precacheController = getOrCreatePrecacheController();
  30. return precacheController.getCacheKeyForURL(url);
  31. }
  32. export { getCacheKeyForURL };