Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created September 18, 2019 11:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
//Ref:https://qiita.com/umamichi/items/0e2b4b1c578e7335ba20
//Ref:https://qiita.com/masanarih0ri/items/0845f312cff5c8d0ec60
const STATIC_DATA = [
'index.html',
'model/museum.glb',
'babylonjs_js/babylonjs.material.min.js',
'js/TeleportCheck.js'
];
self.addEventListener('install', function(e) {
console.log('[ServiceWorker] Install');
e.waitUntil(
caches.open('cache_v1').then(function(cache) {
return cache.addAll(STATIC_DATA);
})
);
});
self.addEventListener('activate', function(e) {
console.log('[ServiceWorker] Activate');
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment