PWA Fundvelo der Caritas.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

service-worker.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // In development, always fetch from the network and do not enable offline support.
  2. // This is because caching would make development more difficult (changes would not
  3. // be reflected on the first load after each change).
  4. 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!!!
  5. const appsettings_url = 'appsettings.json';
  6. const assets = [
  7. './',
  8. '/index.html',
  9. '/account',
  10. '/account/Found',
  11. '/account/Missing',
  12. '/info',
  13. '/caritas_services',
  14. '/lost_found',
  15. '/keydata',
  16. '/keydata/Found',
  17. '/keydata/Missing',
  18. '/conclusion_found',
  19. '/conclusion_missing',
  20. '/doneimage',
  21. '/failureimage',
  22. 'favicon.ico',
  23. 'images/batch_found.png',
  24. 'images/batch_fundvelo.png',
  25. 'images/batch_kulturlegi.png',
  26. 'images/batch_markt.png',
  27. 'images/batch_missing.png',
  28. 'images/caritas_logo.png',
  29. 'images/integrate_logo.png',
  30. 'images/done.png',
  31. 'images/failure.png',
  32. 'images/warning.png',
  33. 'images/icon_camera.png',
  34. 'images/icon_driveupload.png',
  35. 'images/icon_location.png',
  36. 'icons/icon-144.png',
  37. 'css/app.css',
  38. 'css/united/bootstrap.min.css',
  39. 'css/united/_bootswatch.min.css',
  40. 'css/united/_variables.min.css',
  41. '_content/matblazor/dist/matblazor.css',
  42. '_content/matblazor/dist/matblazor.js',
  43. '_content/blazoranimate/blazoranimateinterop.js',
  44. '_content/blazoranimate/aos.css',
  45. '_framework/blazor.webassembly.js',
  46. '_framework/blazor.boot.json',
  47. '_framework/dotnet.5.0.8.js',
  48. 'https://fonts.googleapis.com/css?family=Roboto:300,400,500',
  49. 'https://fonts.googleapis.com/icon?family=Material+Icons',
  50. 'https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap',
  51. 'https://fonts.gstatic.com/s/ubuntu/v15/4iCs6KVjbNBYlgoKfw72nU6AFw.woff2',
  52. 'https://fonts.gstatic.com/s/roboto/v27/KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ.woff2',
  53. 'https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2',
  54. 'https://fonts.gstatic.com/s/materialicons/v85/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2',
  55. 'appsettings.json',
  56. 'manifest.json'
  57. ];
  58. // install event
  59. self.addEventListener('install', event => {
  60. event.waitUntil(
  61. caches.open(staticCacheName).then(cache => {
  62. console.log('caching app assets');
  63. cache.addAll(assets);
  64. })
  65. );
  66. });
  67. // activate event
  68. self.addEventListener('activate', event => {
  69. //delete any caches that aren't in expectedCaches
  70. //which will get rid of site-static-v<n-1>
  71. event.waitUntil(
  72. caches.keys().then(keys => Promise.all(
  73. keys.map(key => {
  74. if (!staticCacheName.includes(key)) {
  75. return caches.delete(key);
  76. }
  77. })
  78. )).then(() => {
  79. console.log('Now ready to handle fetches!');
  80. })
  81. );
  82. });
  83. // fetch events (appsettings are always first fetched from network)
  84. self.addEventListener('fetch', function (event) {
  85. event.respondWith(networkOrCache(event.request).catch(function () {
  86. }));
  87. })
  88. function networkOrCache(request) {
  89. return fetch(request).then(function (response) {
  90. return response.ok ? response : fromCache(request);
  91. }).catch(function () {
  92. return fromCache(request);
  93. });
  94. }
  95. function fromCache(request) {
  96. return caches.open(staticCacheName).then(function (cache) {
  97. return cache.match(request).then(function (matching) {
  98. return matching || Promise.reject('request-not-in-cache');
  99. });
  100. });
  101. }