var myCachName = 'my-cache-v1';
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open(myCachName)
.then(cache =>
cache.addAll[
'/',
'/img',
'/js',
'/css'
])
)
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
if (response) {
return response;
}
return fetch(event.request);
})
);
});
self.addEventListener('activate', function(event) {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cachName => {
if (cachName != myCachName) {
return caches.delete(cachName);
}
})
)
})
);
})
my problem is that I can see that the service worker is working, but when I check the cache there is nothing.
(我的问题是我可以看到服务工作者正在工作,但是当我检查缓存时却什么也没有。)
I couldn't figure what seems to be the issue.(我不知道是什么问题。)
I tried to follow the step here https://developers.google.com/web/fundamentals/primers/service-workers(我尝试按照此处的步骤进行操作https://developers.google.com/web/fundamentals/primers/service-workers)
ask by mohammed alrajeh translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…