Closed brielov closed 2 years ago
A Google search turned up: https://developers.google.com/web/tools/workbox/modules/workbox-cache-expiration
workbox.routing.registerRoute(
/\/images\//,
new workbox.strategies.CacheOnly({
cacheName: 'image-cache',
plugins: [
new workbox.expiration.Plugin({
maxAgeSeconds: 24 * 60 * 60,
}),
],
})
);
or: https://developers.google.com/web/tools/workbox/modules/workbox-build#full_generatesw_config
runtimeCaching: [{
// Match any same-origin request that contains 'api'.
urlPattern: /api/,
// Apply a network-first strategy.
handler: 'NetworkFirst',
options: {
// Fall back to the cache after 10 seconds.
networkTimeoutSeconds: 10,
// Use a custom cache name for this route.
cacheName: 'my-api-cache',
// Configure custom cache expiration.
expiration: {
maxEntries: 5,
maxAgeSeconds: 60,
}
}
}]
If I use cache-only, how can I make it expire after lets say 1 hour?