	
var CACHE_NAME = 'my-site-cache-v1';
var urlsToCache = [
  '/',
  '/include/css/estilo.css',
  '/include/css/xweb.css',
  '/include/css/bootstrap.css',
  '/include/css/swiper.min.css',
  '/include/css/jquery.dataTables.css'
];

self.addEventListener('install', function(event) {
  // Perform install steps
 event.waitUntil(
    //caches.open(CACHE_NAME)
      // .then(function(cache) {
      //   console.log('Cache open!');
      //   //return cache.addAll(urlsToCache);
      // })
  );
});


self.addEventListener('fetch', function(event) {
    event.respondWith(
        caches.match(event.request)
        .then(function(response) {
            // Cache hit - return response
            if (response) {
                return response;
            }
            return fetch(event.request);
        })
    );
});



// let deferredPrompt;

// window.addEventListener('beforeinstallprompt', (e) => {
//   // Prevent the mini-infobar from appearing on mobile
//   e.preventDefault();
//   // Stash the event so it can be triggered later.
//   deferredPrompt = e;
//   // Update UI notify the user they can install the PWA
//   showInstallPromotion();
// });

// buttonInstall.addEventListener('click', (e) => {
//   // Hide the app provided install promotion
//   hideMyInstallPromotion();
//   // Show the install prompt
//   deferredPrompt.prompt();
//   // Wait for the user to respond to the prompt
//   deferredPrompt.userChoice.then((choiceResult) => {
//     if (choiceResult.outcome === 'accepted') {
//       console.log('User accepted the install prompt');
//     } else {
//       console.log('User dismissed the install prompt');
//     }
//   })
// });

// self.addEventListener('activate', event => {
//     // remove old caches
//     event.waitUntil(
//       caches.keys().then(keys => Promise.all(
//         keys.map(key => {
//           if (key != CACHE_NAME) {
//             return caches.delete(key);
//           }
//         })
//       )).then(() => {
//         console.log('Now ready to handle fetches!');
//       })
//     );
// });


