-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
65 lines (65 loc) · 1.72 KB
/
sw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
self.addEventListener('install', function (event) {
// Instalar de inmediato
if (self.skipWaiting) { self.skipWaiting(); }
event.waitUntil(
caches.open('cache01').then(function (cache) {
return cache.addAll([
'/',
'index.html',
'css/main.css',
'img/ahorcado_arboles_fondo.webp',
'img/ahorcado_arboles_frente_fondo.webp',
'img/ahorcado_escenario_fondo.webp',
'img/ahorcado_fondo.webp',
'img/ajax.webp',
'img/flama.webp',
'img/humano.svg',
'img/idalibre-logo.svg',
'img/juan-palma-logo-obscuro.svg',
'img/msnGano.webp',
'img/msnPerdio.webp',
'img/ovni.svg',
'js/librerias/modernizr.js',
'js/librerias/parallax.js',
'js/librerias/require.js',
'js/animaciones/estrellas.js',
'js/owner/alertas.js',
'js/owner/main.js',
'js/owner/validaciones.js',
// 'audios/juegoAmbiente.mp3',
'audios/acierto.mp3',
'audios/error.wav',
'audios/chiflido.mp3',
'audios/admiracion.mp3',
// 'audios/succion.wav',
// 'audios/partida.wav',
'audios/poder.wav',
'audios/golpe.mp3',
'audios/explosion.mp3'
]);
})
);
});
// Cache, falling back to network
self.addEventListener('fetch', function (event) {
event.respondWith(
caches.match(event.request).then(function (response) {
return response || fetch(event.request);
})
);
});
// Elimina archivos de cache viejos
var cacheWhitelist = ['cache01'];
caches.keys().then(function (cacheNames) {
return Promise.all(
cacheNames.map(function (cacheName) {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
})
);
});
caches.keys().then(function (cacheKeys) {
// Muestra en la consola la cache instalada
//console.log('Versión SW: ' + cacheKeys);
});