Since your app is a PWA, you can declare a js file for registration in the navigator.serviceWorker object. This my.js file can contain a const CACHE_VERSION = 1.0
. Updating this value should force the client to download the latest files. See Jeremy Likness’ blog post for more info.
Example:
service-worker.published.js
const CACHE_VERSION = '2021.05.22.001' // Increment each time before deployment.
const cacheNamePrefix = 'offline-cache-';
const cacheName = `${cacheNamePrefix}${CACHE_VERSION}`;
Note: The original one does not work. Replace self.assetsManifest.version with
CACHE_VERSION
const cacheName = ${cacheNamePrefix}${self.assetsManifest.version}
;
Comments