I am trying to precache routes. I have successfully precaches the homepage using
workbox.precaching.precacheAndRoute(['/']);
and this to match route for homepage
workbox.routing.registerRoute(
/^\/$/,
new workbox.strategies.NetworkFirst({
cacheName: 'static-resources',
})
);
I still have other top level routes i will like to match but not sure how.
localhost/subcategory //subcategory and slug attached to it
localhost/product //product and slug attached to it
localhost/product-single // and slug attached to it
How do i write the regular expression for the above
You could use https://regex101.com/ to help you achieve what you want.
A regex like ^localhost(\/.+)?$
should do the trick