GoogleChromeLabs / sw-precache

[Deprecated] A node module to generate service worker code that will precache specific resources so they work offline.
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
5.22k stars 388 forks source link

[Improvement] Multiple cacheNames #305

Closed hrasoa closed 7 years ago

hrasoa commented 7 years ago

It would be good to have multiple cacheNames for storing items by category, example:

jeffposnick commented 7 years ago

If you are using the runtimeCaching option, you can assign a different cache name to each entry:

runtimeCaching: [{
  urlPattern: /\/articles\//,
  handler: 'fastest',
  options: {
    cache: {
      maxEntries: 10,
      name: 'articles-cache' // Choose whatever name you want.
    }
  }
}]

This is useful because you might apply a different strategy or a difference cache expiration limit to different types of requests that are cached at runtime, and using a different cache name reflects those different approaches.

For the precached entries, I don't think there's a significant value to be had from being able to create individually named caches. The precaching logic applies equally to all resources.

hrasoa commented 7 years ago

Ok thanks