I have a web app that stores the data in the browser to support working "offline".
Below is the code in concern:
function getPosCacheData(request, cacheName) {
var storageUrl = request.url;
var checkResponse = navigator.onLine;
return caches.open(cacheName).then(function(cache) {
if (checkResponse == true) {
return fetch(request).then(function(networkResponse) {
if (networkResponse.ok == true) {
cache.put(storageUrl, networkResponse.clone());
}
return networkResponse;
}).catch(function(error) {
return cache.match(storageUrl).then(function(response) {
if (response)
return formFilter(response);
else
return fallPosBackResponse('live');
});
});
} else {
return cache.match(storageUrl).then(function(response) {
if (response) {
return response;
} else {
return fetch(request).then(function(networkResponse) {
if(networkResponse.ok == true){
cache.put(storageUrl, networkResponse.clone());
}
return networkResponse;
}).catch(function(error) {
return fallPosBackResponse('css');
});
}
});
}
});
}
The code above raises this error:
Uncaught (in promise) TypeError: Failed to execute 'put' on 'Cache': Partial response (status code 206) is unsupported
at service-worker.js
The research I did about this error mentions that clearing the cache solves this error, but unfortunately it didn't work.
I do appreciate your kind help fixing this error.