change to multiple caches
This commit is contained in:
parent
62ae5335d8
commit
6dfe4e44b6
@ -18,19 +18,26 @@ var APP_DATA_URLS = [
|
||||
'data/articles.json',
|
||||
];
|
||||
|
||||
var APP_CACHES = [ {
|
||||
name: APP_DATA_CACHE,
|
||||
urls: APP_DATA_URLS
|
||||
},{
|
||||
name: APP_SHELL_CACHE,
|
||||
urls: APP_SHELL_URLS
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
self.addEventListener('install', function(event){
|
||||
event.waitUntil(
|
||||
caches.open(APP_SHELL_CACHE)
|
||||
.then(function(cache){
|
||||
console.log("[Cache] opened: ", APP_SHELL_CACHE);
|
||||
return cache.addAll(APP_SHELL_URLS);
|
||||
})
|
||||
.open(APP_DATA_CACHE)
|
||||
.then(function(cache){
|
||||
console.log("[Cache] opened: ", APP_DATA_CACHE);
|
||||
return cache.addAll(APP_DATA_URLS);
|
||||
})
|
||||
);
|
||||
event.waitUntil(Promise.all(
|
||||
APP_CACHES.map(function (myCache){
|
||||
return caches.open(myCache.name)
|
||||
.then(function (cache){
|
||||
console.log("[Cache] opened: ", myCache.name);
|
||||
return caches.addAll(myCache.urls);
|
||||
});
|
||||
})
|
||||
))
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', function(event){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user