lavas-project / jekyll-pwa

Jekyll plugin for PWA
MIT License
107 stars 19 forks source link

Adding plugins #7

Closed mdelarioja closed 6 years ago

mdelarioja commented 6 years ago

Thanks for the great work on this!

It would be helpful to be able to configure the use of plugins to, for example, set expiration and limit the number of files that are cached.

xiaoiver commented 6 years ago

I already migrated Workbox from v2 to v3 recently. You can upgrade this plugin to v2.0.1. So that you can use Workbox Plugins in your service-worker.js like that:

// my-service-worker.js

workbox.routing.registerRoute(
  new RegExp('/images/'),
  workbox.strategies.cacheFirst({
    cacheName: 'image-cache',
    plugins: [
      new workbox.expiration.Plugin({
        maxEntries: 20,
      }),
    ],
  })
);
mdelarioja commented 6 years ago

@xiaoiver Thank you for all your work on this!