How to store multiple files in the cache for pwa?

0
Hello, I'm creating a system for my site that when the user stays for some reason without a net appears a page of connection that is previously stored in the cache, and this page has an image that stays in the background, but I do not know how to put multiple puts to the system in addition to the page also store the image, can someone help me?

Follow the code:

  self.addEventListener('install', function(event) {
  var offlinePage = new Request('offline.html');
  event.waitUntil(
    fetch(offlinePage).then(function(response) {
      return caches.open('imm-start-offline').then(function(cache) {
        return cache.put(offlinePage, response);
      });
  }));
});
self.addEventListener('fetch', function(event) {
  event.respondWith(
    fetch(event.request).catch(function(error) {
      return caches.open('imm-start-offline').then(function(cache) {
        return cache.match('offline.html');
      });
    }
  ));
});
self.addEventListener('refreshOffline', function(response) {
  return caches.open('imm-start-offline').then(function(cache) {
    return cache.put(offlinePage, response);
  });
});
    
asked by anonymous 14.06.2018 / 21:32

0 answers