Reputation: 5407
I've setup a service worker on my blog, the home page correctly loads from the Service Worker cache, however visiting 'posts' that I have previously visited while Chrome is set to be online they load, and in the developer tools they show as 'from ServiceWorker' as expected.
However when I use the developer tools to set Chrome to offline, the pages are returning a status of 'failed'
My question is why is this issue occurring?
ServiceWorker registration script
Upvotes: 1
Views: 493
Reputation: 6530
Using a regex in the path instead:
self.toolbox.router.get('/(.*)', function (request, values, options)
should do the trick without having 2 paths registered.
Upvotes: 1
Reputation: 5407
Due to the URL structure of the site being
https://example.com/YYYY/MM/DD/post-title
I had to add a secondary block to handle the paths
self.toolbox.router.get('/**/*', function (request, values, options) {
This resolved the issue for me, as the existing block
self.toolbox.router.get('/*', function (request, values, options)
was not sufficient
Upvotes: 1