July 2018
Intermediate to advanced
354 pages
8h 51m
English
User activity and network requests are not the only times you can cache a network resource:

You can also use a push message to initiate caching responses, as shown in the following code:
//On push message
function parsePushMessage(message){
//parse the message
If(message.update){
//notify user of background update process here
caches.open(preCacheName).then(cache =>{
return cache.addAll(message.urls);
});
}
}
self.addEventListener('push', event => {
parsePushMessage(event.data);
});
In this strategy, the push event handler determines the type of message action. If it is a notice to update the application, it initiates ...
Read now
Unlock full access