How would one configure sw-precache to serve index.html
for multiple dynamic routes?
This is for an Angular app that has index.html
as the entry point. The current setup allows the app to be accessable offline only through /
. So if a user go to /articles/list/popular
as an entry point while offline they won't be able to browse it and would be given you're offline message. (although when online they'd be served the same index.html
file on all requests as an entry point)
Can dynamicUrlToDependencies be used to do this? Or does this need to be handled by writing a separate SW script? Something like the following would do?
function serveIndexCacheFirst() {
var request = new Request(INDEX_URL);
return toolbox.cacheFirst(request);
}
toolbox.router.get(
'(/articles/list/.+)|(/profiles/.+)(other-patterns)',
serveIndexCacheFirst);