Closed manishbhatt94 closed 4 years ago
Add reversion string to the mainfest of document URL, will fix.
@manishbhatt94 @GeoffZhu @timneutkens I would like to give it a shot :clap: I'm new here, it would be great if you could point me in the right direction such as the required files to work upon :+1:
Going to close this as it's been open for over a year with no other people upvoting it / no contribution to solve the question.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Hi, @timneutkens @timothyis @leo First of all thanks for making and maintaining this awesome project! You guys have truly made SSR a breeze 🥇
This issue is related to https://github.com/zeit/next.js/issues/5530
So I need to cache the
page
documents for my site to be completely available offline. For that I'm usingworkbox
andworkbox-webpack-plugin
.I'm caching all
page
bundles and documents in the service worker install step, usingworkbox.precaching
module. How this precaching module works is that it picks up all webpack emitted assets, hashes each file contents and populates the assets'url
andrevision
in an array calledprecacheManifest
. Now since Next.js doesn't emit any HTML files, it's not by default picked up by theworkbox.precaching
module. And so, I had to append the generatedprecacheManifest
array with the list of pages' URLs, like so:Everything works fine, bundles and documents all get cached. And the site totally works fully even when offline.
But the problem with my approach is that when I build and deploy my app with some changes, the new service worker gets activated, new bundles are fetched and cached (since their hash changes and workbox manages updation by keeping track of revision in IndexedDB)... but since the documents don't have a revision or even anything unique in their URL, the documents don't get updated in the cache. And workbox follows a
cacheFirst
strategy forprecached
resources and therefore the old documents with the old bundle paths are being loaded. This gives 404 when trying to fetch page bundles with old paths - leading to the app not working at all after an update.I need help in figuring out what approach I should follow here, and what are the general practises employed in this type of scenario.
Thanks in advance