If I have a website that is a PWA, how does this help me with database results? For example, if I have a list of products or names, doesn't matter, how do Service Workers help me with this? On Google's Dev site it shows:
var networkDataReceived = false;
startSpinner();
// fetch fresh data
var networkUpdate = fetch('/data.json').then(function(response) {
return response.json();
}).then(function(data) {
networkDataReceived = true;
updatePage(data);
});
// fetch cached data
caches.match('/data.json').then(function(response) {
if (!response) throw Error("No data");
return response.json();
}).then(function(data) {
// don't overwrite newer network data
if (!networkDataReceived) {
updatePage(data);
}
}).catch(function() {
// we didn't get cached data, the network is our last hope:
return networkUpdate;
}).catch(showErrorMessage).then(stopSpinner());
But what if my results are always different? Someone make lookup cars one minute and the next shirts. I do not understand what a PWA Service Worker can do here other than give the illusion of speed.
Aucun commentaire:
Enregistrer un commentaire