I implement a service Worker. I looks pretty good, activating without errors, ...
But I cannot see something there:
sw.min.js:
workbox.routing.registerRoute(
({request}) => request.destination === 'style',
new workbox.strategies.NetworkFirst({
// cacheName: cacheNamecss,
plugins: [
new workbox.expiration.ExpirationPlugin({
maxEntries: 20,
maxAgeSeconds: 7 * 24 * 60 * 60
}),
new workbox.cacheableResponse.CacheableResponsePlugin({
statuses: [0, 200],
headers: {'X-Is-Cacheable': 'yes'}
})
]
}));
This is in Google Chrome's
Application
-> Service Workers
Try this code in your service worker:
This approach is called
stale-while-revalidate
https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook#stale-while-revalidate
This means: If you fetch a page, i the service worker check if there is something in the cache and returns it from the cache to you, after returning it from the cache the service worker makes an request to the network and saves that request into the old cache.
Next time you refresh you will see the updated version.
On good approach is also: "cache with fallback to network"
This simply means: Take a look into the cache if there is something stored, if not then fetch it from the network.