Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add html pages to runtime cache #10

Open
WPACenter opened this issue Jun 12, 2018 · 2 comments
Open

How to add html pages to runtime cache #10

WPACenter opened this issue Jun 12, 2018 · 2 comments

Comments

@WPACenter
Copy link

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: - route: /.*\.(?:png|jpg|jpeg|svg|gif|html)/ strategy: cacheFirst

@mdelarioja
Copy link

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

route: /^[^.]+$/

@xiaoiver
Copy link
Contributor

xiaoiver commented Jul 5, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants