getCacheKeyForURL.mjs 1.1 KB

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