Open IamBramer opened 6 years ago
Use a Cache then network approach like shown in the Offline Cookbook. This will show the cache first and then update the page when the network data arrives.
networkFirst
so that it loads these resources from the web first. Also set the maxEntries
that can be held in these caches to 10. Example given:{
runtimeCaching: [{
urlPattern: /\/projects\//,
handler: 'networkFirst',
options: {
cache: {
maxEntries: 10,
name: 'projects-cache'
}
}
}, {
urlPattern: /\/words\//,
handler: 'networkFirst',
options: {
cache: {
maxEntries: 10,
name: 'words-cache'
}
}
}],
// ...other options as needed...
}
Remember to register service worker.
Setup a service worker that has proper cache invalidation. The below github project has a service worker that can be built with gulp and will hash files.
https://github.com/GoogleChromeLabs/sw-precache