lavas-project / jekyll-pwa

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

How to add html pages to runtime cache #10

Open WPACenter opened 6 years ago

WPACenter commented 6 years ago

I'd like the html of pages that are visited to be added to the runtime cache; however, I am unsure about how to do this. The example below does a good job of caching all images, but does not catch the html pages.

` runtime_cache:

mdelarioja commented 6 years ago

Assuming you are using pretty permalinks, something like this should work:

route: /^[^.]+$/

xiaoiver commented 6 years ago

v2.0.1 has been published. We use Workbox V3 now, which means you don't need to write these regexp in _config.yml. You can write them directly in your service-worker.js:

workbox.routing.registerRoute(
    /.*\.(?:png|jpg|jpeg|svg|gif|html)/,
    workbox.strategies. cacheFirst()
);

See v2 -> v3 migration guide for more informations.