allow updating cache of unhashed assets (like config) in service worker
This commit is contained in:
parent
1555b0f4bc
commit
13428bd03c
1 changed files with 7 additions and 1 deletions
|
@ -160,8 +160,14 @@ async function updateCache(request, response) {
|
|||
cache.put(request, response.clone());
|
||||
} else if (request.url.startsWith(baseURL)) {
|
||||
let assetName = request.url.substr(baseURL.length);
|
||||
let cacheName;
|
||||
if (HASHED_CACHED_ON_REQUEST_ASSETS.includes(assetName)) {
|
||||
const cache = await caches.open(hashedCacheName);
|
||||
cacheName = hashedCacheName;
|
||||
} else if (UNHASHED_PRECACHED_ASSETS.includes(assetName)) {
|
||||
cacheName = unhashedCacheName;
|
||||
}
|
||||
if (cacheName) {
|
||||
const cache = await caches.open(cacheName);
|
||||
await cache.put(request, response.clone());
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue