| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- // In development, always fetch from the network and do not enable offline support.
- // This is because caching would make development more difficult (changes would not
- // be reflected on the first load after each change).
-
- const staticCacheName = 'site-static-v-0-2-0'; // IMPORTANT: CHANGE THE VERSION IN THIS NAME EVERY TIME THE APP IS DEPLOYED ON SERVER WITH CHANGES!!!
- const appsettings_url = 'appsettings.json';
- const assets = [
- './',
- '/index.html',
- '/account',
- '/account/Found',
- '/account/Missing',
- '/info',
- '/caritas_services',
- '/lost_found',
- '/keydata',
- '/keydata/Found',
- '/keydata/Missing',
- '/conclusion_found',
- '/conclusion_missing',
- '/doneimage',
- '/failureimage',
- 'favicon.ico',
- 'images/batch_found.png',
- 'images/batch_fundvelo.png',
- 'images/batch_kulturlegi.png',
- 'images/batch_markt.png',
- 'images/batch_missing.png',
- 'images/caritas_logo.png',
- 'images/integrate_logo.png',
- 'images/done.png',
- 'images/failure.png',
- 'images/warning.png',
- 'images/icon_camera.png',
- 'images/icon_driveupload.png',
- 'images/icon_location.png',
- 'icons/icon-144.png',
- 'css/app.css',
- 'css/united/bootstrap.min.css',
- 'css/united/_bootswatch.min.css',
- 'css/united/_variables.min.css',
- '_content/matblazor/dist/matblazor.css',
- '_content/matblazor/dist/matblazor.js',
- '_content/blazoranimate/blazoranimateinterop.js',
- '_content/blazoranimate/aos.css',
- '_framework/blazor.webassembly.js',
- '_framework/blazor.boot.json',
- '_framework/dotnet.5.0.8.js',
- 'https://fonts.googleapis.com/css?family=Roboto:300,400,500',
- 'https://fonts.googleapis.com/icon?family=Material+Icons',
- 'https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap',
- 'https://fonts.gstatic.com/s/ubuntu/v15/4iCs6KVjbNBYlgoKfw72nU6AFw.woff2',
- 'https://fonts.gstatic.com/s/roboto/v27/KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ.woff2',
- 'https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2',
- 'https://fonts.gstatic.com/s/materialicons/v85/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2',
- 'appsettings.json',
- 'manifest.json'
- ];
-
-
- // install event
- self.addEventListener('install', event => {
- event.waitUntil(
- caches.open(staticCacheName).then(cache => {
- console.log('caching app assets');
- cache.addAll(assets);
- })
- );
- });
-
- // activate event
- self.addEventListener('activate', event => {
- //delete any caches that aren't in expectedCaches
- //which will get rid of site-static-v<n-1>
- event.waitUntil(
- caches.keys().then(keys => Promise.all(
- keys.map(key => {
- if (!staticCacheName.includes(key)) {
- return caches.delete(key);
- }
- })
- )).then(() => {
- console.log('Now ready to handle fetches!');
- })
- );
- });
-
- // fetch events (appsettings are always first fetched from network)
- self.addEventListener('fetch', function (event) {
- event.respondWith(networkOrCache(event.request).catch(function () {
- }));
- })
-
- function networkOrCache(request) {
- return fetch(request).then(function (response) {
- return response.ok ? response : fromCache(request);
- }).catch(function () {
- return fromCache(request);
- });
- }
-
- function fromCache(request) {
- return caches.open(staticCacheName).then(function (cache) {
- return cache.match(request).then(function (matching) {
- return matching || Promise.reject('request-not-in-cache');
- });
- });
- }
|