1
我已经编写了下面的代码来检查特定的URL是否已经在服务工作者缓存中?但即使该URL不在缓存中,它也会返回/“控制台在缓存中找到”。调用上面的函数检查服务工作者缓存中是否存在URL
var isExistInCache = function(request){
return caches.open(this.cacheName).then(function(cache) {
return cache.match(request).then(function(response){
debug_("Found in cache "+response,debug);
return true;
},function(err){
debug_("Not found in cache "+response,debug);
return false;
});
})
}
为
cache.isExistInCache('http://localhost:8080/myroom.css').then(function(isExist){
console.log(isExist);
})