Commit 270aca3f authored by Julien Enselme's avatar Julien Enselme

Increase logging in SW

To better understand what is going on.
parent c64740f1
......@@ -60,10 +60,12 @@ function tryToFetchAndSaveInCache(event, cacheName) {
}
function fetchAndSaveInCache(event, cacheName) {
console.log(`[SW] Fetching ${event.request.url}`);
return fetch(event.request)
.then(res => {
const requestSucceeded = res.status >= 200 && res.status <= 300;
if (!requestSucceeded) {
console.log('[SW] Request failed.');
return res;
}
......@@ -71,6 +73,7 @@ function fetchAndSaveInCache(event, cacheName) {
.then(cache => {
// We can read a response only once. So if we don't clone it here,
// we won't be able to see anything in the browser.
console.log('[SW] Saving in the cache.');
cache.put(event.request.url, res.clone());
return res;
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment