这里有两个问题。
首先,关于
fetch
ServiceWorker
,我查了一下
缓存包含我正在获取的文件,而不是当前缓存版本。
取来
此的事件侦听器:
self.addEventListener('fetch', e => {
e.respondWith(
caches.open(currentVersion).then(cache => {
return cache.match(e.request).then(resp => {
// Request found in current cache, or fetch the file
return resp || fetch(e.request).then(response => {
// Cache the newly fetched file for next time
cache.put(e.request, response.clone());
return response;
// Fetch failed, user is offline
}).catch(() => {
// Look in the whole cache to load a fallback version of the file
return caches.match(e.request).then(fallback => {
return fallback;
});
});
});
})
);
});
最后一个问题是,仅仅重新加载页面(F5)并不会改变
.
为了新的
服务人员