Guest User

Untitled

a guest
Jan 18th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. // Chrome's currently missing some useful cache methods,
  2. // this polyfill adds them.
  3. importScripts('serviceworker-cache-polyfill.js');
  4.  
  5. // Here comes the install event!
  6. // This only happens once, when the browser sees this
  7. // version of the ServiceWorker for the first time.
  8. self.addEventListener('install', function(event) {
  9. // We pass a promise to event.waitUntil to signal how
  10. // long install takes, and if it failed
  11. event.waitUntil(
  12. // We open a cache…
  13. caches.open('simple-sw-v1').then(function(cache) {
  14. // And add resources to it
  15. return cache.addAll([
  16. './',
  17. 'style.css',
  18. 'logging.js'
  19. ]);
  20. })
  21. );
  22. });
  23.  
  24. // The fetch event happens for the page request with the
  25. // ServiceWorker's scope, and any request made within that
  26. // page
  27. self.addEventListener('fetch', function(event) {
  28. // Calling event.respondWith means we're in charge
  29. // of providing the response. We pass in a promise
  30. // that resolves with a response object
  31. event.respondWith(
  32. // First we look for something in the caches that
  33. // matches the request
  34. caches.match(event.request).then(function(response) {
  35. // If we get something, we return it, otherwise
  36. // it's null, and we'll pass the request to
  37. // fetch, which will use the network.
  38. return response || fetch(event.request);
  39. })
  40. );
  41. });
  42.  
  43. {
  44. "short_name": "Ferie Med Mening",
  45. "name": "Ferie Med Mening",
  46. "icons": [
  47. {
  48. "src": "https://feriemedmening.xyz/wp-content/uploads/2018/01/ikon-1.png",
  49. "type": "image/png",
  50. "sizes": "48x48"
  51. },
  52. {
  53. "src": "https://feriemedmening.xyz/wp-content/uploads/2018/01/ikon-1.png",
  54. "type": "image/png",
  55. "sizes": "96x96"
  56. },
  57. {
  58. "src": "https://feriemedmening.xyz/wp-content/uploads/2018/01/ikon-1.png",
  59. "type": "image/png",
  60. "sizes": "192x192"
  61. }
  62. ],
  63. "start_url": "https://feriemedmening.xyz/"
  64. "score_url": "https://feriemedmening.xyz/"
  65. "theme_color": "#2ABB9C"
  66. }
Add Comment
Please, Sign In to add comment