Open mgburns opened 3 years ago
I can confirm this was also a problem for me.. I am making a gridsome shopify starter and had a similar issue (routes without a trailing /
would not load css assets due to a cache issue). After debugging the whole site (reinstalling dependencies and making sure route paths were correct), setting the disableTemplatedURLs
to true
was the fix for me.
We ran into a production issue with this plugin that appears to be caused by the issue first reported in #36:
gridsome-plugin-i18n
The i18n plugin was configured with the
enablePathRewrite
set totrue
, so that old URLs would automatically redirect to their locale-prefixed versions (ex:/about
->/en/about
).As soon as the second deploy went out we received reports of users getting blank and un-styled pages. We were able to reproduce by visiting pages that had the service worker registered from 1 active. If you visited a page without the trailing slash it would break, as a cached version fo the page was being served by the service worker that referenced static assets that no longer existed.
We traced it down to the bug reported in #36 and were able to resolve it by setting
disableTemplatedURLs
totrue
.My question is -- what is the use case that led to the
templatedURLs
logic in https://github.com/rishabh3112/gridsome-plugin-pwa/blob/master/src/files/service-worker.js#L22-L32?Workbox Build will automatically find all of the pages that need to be pre-cached using the
glob
options, and AFAICTtemplatedURLs
is only needed for server-rendered URLs:See https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.generateSW
I don't think this applies to a static site generated with a tool like Gridsome, and worst case leads to stale cache entries that can break in ways that are hard to recover from without having users clear the cache storage.