Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. self.addEventListener('install', (e) => {
  2. console.log('[Service Worker] Install');
  3. e.waitUntil(
  4. caches.open(cacheName).then((cache) => {
  5. console.log('[Service Worker] Caching all: app shell and content');
  6. return cache.addAll(contentToCache);
  7. })
  8. );
  9. });
  10.  
  11. self.addEventListener('fetch', (e) => {
  12. e.respondWith(
  13. caches.match(e.request).then((r) => {
  14. console.log('[Service Worker] Fetching resource: '+e.request.url);
  15. return r || fetch(e.request).then((response) => {
  16. return caches.open(cacheName).then((cache) => {
  17. console.log('[Service Worker] Caching new resource: '+e.request.url);
  18. cache.put(e.request, response.clone());
  19. return response;
  20. });
  21. });
  22. })
  23. );
  24. });
  25.  
  26. var cacheName = 'sw';
  27. var contentToCache = [
  28. './index.html',
  29. './style.css',
  30. './manifest.json',
  31. './produits.csv',
  32. './js/DecoderWorker.js',
  33. './js/exif.js',
  34. './js/job.js',
  35. './js/app.js',
  36. './favicon.ico',
  37. './images/logo.png',
  38. './images/barcode-scanner.png',
  39. './images/icon-setup.png',
  40. './images/icon-transmit.png',
  41. './icons/icon-32.png',
  42. './icons/icon-64.png',
  43. './icons/icon-96.png',
  44. './icons/icon-128.png',
  45. './icons/icon-168.png',
  46. './icons/icon-192.png',
  47. './icons/icon-256.png',
  48. './icons/icon-512.png'
  49. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement