kopia lustrzana https://github.com/OpenBuilds/OpenBuilds-CONTROL
30 wiersze
848 B
JavaScript
30 wiersze
848 B
JavaScript
self.addEventListener('install', function(event) {
|
|
console.log('[Service Worker] Installing Service Worker ...', event);
|
|
event.waitUntil(
|
|
caches.open('static').then(function(cache) {
|
|
cache.addAll(['/', '/index.html', '/app.js', '/manifest.json']);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener('activate', function(event) {
|
|
console.log('[Service Worker] Activating Service Worker ....', event);
|
|
});
|
|
|
|
self.addEventListener('fetch', function(event) {
|
|
event.respondWith(
|
|
caches.match(event.request).then(function(response) {
|
|
if (response) {
|
|
return response;
|
|
} else {
|
|
return fetch(event.request).then(function(res) {
|
|
return caches.open('dynamic').then(function(cache) {
|
|
cache.put(event.request.url, res.clone());
|
|
return res;
|
|
});
|
|
});
|
|
}
|
|
})
|
|
);
|
|
});
|