In this answer When and how does a PWA update itself? it is explained that a PWA is updated if manifest.json
links are updated or if one character is modified from the service-worker.js
file.
But what do we exactly mean by "updated"? Does this mean the install
event is re-triggered and that all the listed files below are re-downloaded?
Is there a documentation confirming this is the case for all browsers on Android and iOS? (I don't know if the latter uses PWA the same way than on Android)
Here is an example service-worker.js
file:
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open('myapp-store').then((cache) => cache.addAll([
'/app/index.html',
'/app/file1.jpg',
'/app/file2.mp3',
'/app/file3.png',
])),
);
});
self.addEventListener('fetch', (e) => {
console.log(e.request.url);
e.respondWith(
caches.match(e.request).then((response) => response || fetch(e.request)),
);
});