Added service worker regisration refresh BOD-73
This commit is contained in:
@@ -58,6 +58,16 @@ function registerValidSW(swUrl, config) {
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then((registration) => {
|
||||
// Start addition---
|
||||
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#manual_updates
|
||||
// Added code, as our application will be open for a long time and we are a SPA, we need
|
||||
// to trigger checks for updates frequently
|
||||
setInterval(() => {
|
||||
console.log("Checking if service worker was updated in server");
|
||||
registration.update();
|
||||
}, 15 * 60 * 1000); // Every 15 mins check
|
||||
// End addition---
|
||||
|
||||
registration.onupdatefound = () => {
|
||||
const installingWorker = registration.installing;
|
||||
if (installingWorker == null) {
|
||||
|
||||
Reference in New Issue
Block a user