mirror of https://github.com/dirtbags/moth.git
Hiding some debug messages
Only cache results for HTTP GETs
This commit is contained in:
parent
3fc84e532e
commit
18ee0ab3a2
|
@ -28,16 +28,16 @@ self.addEventListener('fetch', function(event) {
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
fetch(event.request)
|
fetch(event.request)
|
||||||
.catch(function(evt) {
|
.catch(function(evt) {
|
||||||
console.log("Falling back to cache for " + event.request.url);
|
//console.log("Falling back to cache for " + event.request.url);
|
||||||
cache_used = true;
|
cache_used = true;
|
||||||
return caches.match(event.request, {ignoreSearch: true});
|
return caches.match(event.request, {ignoreSearch: true});
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
if (res && res.ok) {
|
if (res && res.ok) {
|
||||||
let res_clone = res.clone();
|
let res_clone = res.clone();
|
||||||
if (! cache_used ) {
|
if (! cache_used && event.request.method == "GET" ) {
|
||||||
caches.open(cacheName).then(function(cache) {
|
caches.open(cacheName).then(function(cache) {
|
||||||
cache.put(event.request, res_clone);
|
cache.put(event.request, res_clone);
|
||||||
console.log("Storing " + event.request.url + " in cache");
|
//console.log("Storing " + event.request.url + " in cache");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Reference in New Issue