Skip to content

Instantly share code, notes, and snippets.

@manolinux
manolinux / caching_service_worker.js
Created June 11, 2018 15:17
Caching service worker
// Your code here...
workbox.routing.registerRoute(
/\.(?:png|gif|jpg|jpeg|svg)$/,
workbox.strategies.cacheFirst({
cacheName: 'images',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 60,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
}),