Node.js PWA

I’m creating a node.js PWA and was able to get most of it working (using @ben’s tutorial here for a php pwa spa plus a bunch of googling).

in any case, the dynamic cache seems to work fine, as once i visit a page, i can revisit while offline. however, i can’t seem to get fallback.ejs to load in place of any page if i’ve never been to a page before going offline. i check the local storage and its blank.

i think its likely because of the default folder hierarchy. the service worker is in the public folder, which is set to be the web root folder in project settings (as default). but all the content pages are set to be in the views folder:

so then the topmost level the serviceworker.js can go is the public folder. my question is, what is the best way to fix this? should i change the webroot folder to the main project folder (one level higher than “public”), and if so, what are the downsides? seems like not a good idea…

if not, how do i get the pages from the views folder, etc to cache?

any help would be greatly appreciated!

Community Page
Last updated: