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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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-v1'; // 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. 'favicon.ico',
  22. 'images/batch_found.png',
  23. 'images/batch_fundvelo.png',
  24. 'images/batch_kulturlegi.png',
  25. 'images/batch_markt.png',
  26. 'images/batch_missing.png',
  27. 'images/caritas_logo.png',
  28. 'images/integrate_logo.png',
  29. 'images/done.png',
  30. 'images/icon_camera.png',
  31. 'images/icon_driveupload.png',
  32. 'images/icon_location.png',
  33. 'icons/icon-144.png',
  34. 'css/app.css',
  35. 'css/united/bootstrap.min.css',
  36. 'css/united/_bootswatch.min.css',
  37. 'css/united/_variables.min.css',
  38. '_content/matblazor/dist/matblazor.css',
  39. '_content/matblazor/dist/matblazor.js',
  40. '_content/blazoranimate/blazoranimateinterop.js',
  41. '_content/blazoranimate/aos.css',
  42. '_framework/blazor.webassembly.js',
  43. '_framework/blazor.boot.json',
  44. '_framework/dotnet.5.0.7.js',
  45. 'https://fonts.googleapis.com/css?family=Roboto:300,400,500',
  46. 'https://fonts.googleapis.com/icon?family=Material+Icons',
  47. 'https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap',
  48. 'https://fonts.gstatic.com/s/ubuntu/v15/4iCs6KVjbNBYlgoKfw72nU6AFw.woff2',
  49. 'https://fonts.gstatic.com/s/roboto/v27/KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ.woff2',
  50. 'https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2',
  51. 'https://fonts.gstatic.com/s/materialicons/v85/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2',
  52. 'appsettings.json',
  53. 'manifest.json'
  54. ];
  55. // install event
  56. self.addEventListener('install', event => {
  57. event.waitUntil(
  58. caches.open(staticCacheName).then(cache => {
  59. console.log('caching app assets');
  60. cache.addAll(assets);
  61. })
  62. );
  63. });
  64. // activate event
  65. self.addEventListener('activate', event => {
  66. //delete any caches that aren't in expectedCaches
  67. //which will get rid of site-static-v<n-1>
  68. event.waitUntil(
  69. caches.keys().then(keys => Promise.all(
  70. keys.map(key => {
  71. if (!staticCacheName.includes(key)) {
  72. return caches.delete(key);
  73. }
  74. })
  75. )).then(() => {
  76. console.log('Now ready to handle fetches!');
  77. })
  78. );
  79. });
  80. // fetch events (appsettings are always first fetched from network)
  81. self.addEventListener('fetch', event => {
  82. if (event.request.url.endsWith(appsettings_url)) {
  83. fetch(event.request).then(function (response) {
  84. return caches.open(staticCacheName).then(function (cache) {
  85. console.log('update cache');
  86. cache.put(event.request, response.clone());
  87. return response;
  88. });
  89. });
  90. } else {
  91. event.respondWith(
  92. caches.match(event.request).then(cacheRes => {
  93. return cacheRes || fetch(event.request);
  94. })
  95. );
  96. }
  97. });