about summary refs log tree commit diff
path: root/MatrixUtils.Web/wwwroot
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixUtils.Web/wwwroot')
-rw-r--r--MatrixUtils.Web/wwwroot/index.html23
-rw-r--r--MatrixUtils.Web/wwwroot/service-worker.published.js22
-rw-r--r--MatrixUtils.Web/wwwroot/sw-registrator.js2
3 files changed, 31 insertions, 16 deletions
diff --git a/MatrixUtils.Web/wwwroot/index.html b/MatrixUtils.Web/wwwroot/index.html

index 0a80cff..3334426 100644 --- a/MatrixUtils.Web/wwwroot/index.html +++ b/MatrixUtils.Web/wwwroot/index.html
@@ -3,31 +3,32 @@ <head> <meta charset="utf-8"/> - <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/> + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <title>MatrixUtils.Web</title> <base href="/"/> - <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet"/> - <link href="css/app.css" rel="stylesheet"/> + <link rel="preload" id="webassembly"/> + <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css"/> + <link rel="stylesheet" href="css/app.css"/> + <link rel="icon" type="image/png" href="favicon.png"/> + <link href="MatrixUtils.Web.styles.css" rel="stylesheet"/> <link rel="manifest" href="rmu.webmanifest"/> <link rel="apple-touch-icon" sizes="512x512" href="icon-512.png"/> - <link href="favicon.png" rel="icon" type="image/png"/> - <link href="MatrixUtils.Web.styles.css" rel="stylesheet"/> - <link rel="preload" id="webassembly"/> + <link rel="apple-touch-icon" sizes="192x192" href="icon-192.png"/> </head> <body> <div id="app"> <svg class="loading-progress"> - <circle cx="50%" cy="50%" r="40%"/> - <circle cx="50%" cy="50%" r="40%"/> + <circle r="40%" cx="50%" cy="50%"/> + <circle r="40%" cx="50%" cy="50%"/> </svg> <div class="loading-progress-text"></div> </div> <div id="blazor-error-ui"> An unhandled error has occurred. - <a class="reload" href="">Reload</a> - <a class="dismiss">🗙</a> + <a href="." class="reload">Reload</a> + <span class="dismiss">🗙</span> </div> <script> function getWidth(element) { @@ -65,7 +66,7 @@ image.src = url; } </script> - <script src="_framework/blazor.webassembly.js"></script> + <script src="_framework/blazor.webassembly#[.{fingerprint}].js"></script> <!-- <script>navigator.serviceWorker.register('service-worker.js');</script>--> <script src="sw-registrator.js"></script> </body> diff --git a/MatrixUtils.Web/wwwroot/service-worker.published.js b/MatrixUtils.Web/wwwroot/service-worker.published.js
index 9219755..aafb48c 100644 --- a/MatrixUtils.Web/wwwroot/service-worker.published.js +++ b/MatrixUtils.Web/wwwroot/service-worker.published.js
@@ -9,7 +9,7 @@ self.addEventListener('fetch', event => event.respondWith(onFetch(event))); const cacheNamePrefix = 'offline-cache-'; const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`; const offlineAssetsInclude = [// Standard resources - /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/, /* Extra known-static paths */ + /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/, /\.webmanifest$/, /* Extra known-static paths */ /\/_matrix\/media\/.{2}\/download\//, /api\.dicebear\.com\/6\.x\/identicon\/svg/]; const offlineAssetsExclude = [/^service-worker\.js$/]; @@ -28,7 +28,7 @@ async function onInstall(event) { const assetsRequests = self.assetsManifest.assets .filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url))) .filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url))) - .map(asset => new Request(asset.url, {integrity: asset.hash, cache: 'no-cache'})); + .map(asset => new Request(asset.url, {cache: 'no-cache'})); /* integrity: asset.hash */ await caches.open(cacheName).then(cache => cache.addAll(assetsRequests)); } @@ -48,12 +48,26 @@ async function onFetch(event) { // For all navigation requests, try to serve index.html from cache, // unless that request is for an offline resource. // If you need some URLs to be server-rendered, edit the following check to exclude those URLs - const shouldServeIndexHtml = event.request.mode === 'navigate' && !manifestUrlList.some(url => url === event.request.url); + const shouldServeIndexHtml = event.request.mode === 'navigate' + && !manifestUrlList.some(url => url === event.request.url); const request = shouldServeIndexHtml ? 'index.html' : event.request; const shouldCache = offlineAssetsInclude.some(pattern => pattern.test(request.url)); const cache = await caches.open(cacheName); + + if (request !== 'index.html' && request.url.endsWith("_framework/dotnet.js")) { + // return `_framework/dotnet.<hash>.js` from cache to avoid integrity errors + const dotnetJsUrl = manifestUrlList.find(url => /_framework\/dotnet\.[a-z0-9]+\.js$/.test(url)); + if (dotnetJsUrl) { + cachedResponse = await cache.match(dotnetJsUrl); + if (cachedResponse) { + console.log("Service worker caching: serving dotnet.js from cache: ", dotnetJsUrl); + return cachedResponse; + } + } else console.warn("Service worker caching: could not find dotnet.hash.js in manifest", {request, manifestUrlList}); + } + cachedResponse = await cache.match(request); let exception; let fetched; @@ -72,7 +86,7 @@ async function onFetch(event) { fetched, shouldCache, request, exception, cachedResponse, url: request.url, } Object.keys(consoleLog).forEach(key => consoleLog[key] == null && delete consoleLog[key]) - if(consoleLog.exception) + if (consoleLog.exception) console.log("Service worker caching: ", consoleLog) } diff --git a/MatrixUtils.Web/wwwroot/sw-registrator.js b/MatrixUtils.Web/wwwroot/sw-registrator.js
index 67aa5cb..b57d26a 100644 --- a/MatrixUtils.Web/wwwroot/sw-registrator.js +++ b/MatrixUtils.Web/wwwroot/sw-registrator.js
@@ -15,7 +15,7 @@ window.updateAvailable = new Promise((resolve, reject) => { // detect updates every minute setInterval(() => { registration.update(); - }, 5 * 1000); // 60000ms -> check each minute + }, 30 * 1000); // 60000ms -> check each minute registration.onupdatefound = () => { const installingServiceWorker = registration.installing;