admin管理员组

文章数量:1327804

Is there a way to match wildcard URLs on a serviceWorker's install event?

I'd like to be able to match something like *.bundle.js.

self.addEventListener('install', event => {
  event.waitUntil(
    caches.open(latest.cache).then(cache => {
      return cache.addAll([
        '/',
        '*.bundle.js'
      ])
    })
  )
})

Is there a way to match wildcard URLs on a serviceWorker's install event?

I'd like to be able to match something like *.bundle.js.

self.addEventListener('install', event => {
  event.waitUntil(
    caches.open(latest.cache).then(cache => {
      return cache.addAll([
        '/',
        '*.bundle.js'
      ])
    })
  )
})
Share Improve this question edited Feb 18, 2017 at 20:17 Raphael Rafatpanah asked Feb 18, 2017 at 20:11 Raphael RafatpanahRaphael Rafatpanah 20k28 gold badges105 silver badges174 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

I don't think that's possible since you're not caching strings or urls, but requests.

There is a thing from Google that might be of use, the sw-precache module. This can generate a service worker through Gulp or the mandline. It works alongside the service worker toolbox.

本文标签: javascriptCan cacheaddAll accept wildcard matchesStack Overflow