[HTML5] PWA service worker prefers cached version.

Use an offline first approach, where we prefer the cached version over
the network one.
This forces games using PWA to always re-export the project and not just
the PCK, so that the service worker version gets updated correctly, and
the end-user cache is correctly cleared on update.
This commit is contained in:
Fabio Alessandrelli 2021-12-21 14:41:26 +01:00
parent 95719930a8
commit cc4612277b
4 changed files with 112 additions and 63 deletions

View file

@ -189,6 +189,9 @@ const Engine = (function () {
preloader.preloadedFiles.length = 0; // Clear memory
me.rtenv['callMain'](me.config.args);
initPromise = null;
if (me.config.serviceWorker && 'serviceWorker' in navigator) {
navigator.serviceWorker.register(me.config.serviceWorker);
}
resolve();
});
});