Created
August 28, 2019 06:14
-
-
Save tkssharma/858909fd48f4642ece3cd5c4adc138dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workbox.routing.registerRoute( | |
new RegExp('.css$'), | |
workbox.strategies.cacheFirst({ | |
cacheName: 'poc-cache-Stylesheets', | |
plugins: [ | |
new workbox.expiration.Plugin({ | |
maxAgeSeconds: 60 * 60 * 24 * 7, // cache for one week | |
maxEntries: 20, // only cache 20 request | |
purgeOnQuotaError: true, | |
}), | |
], | |
}), | |
); | |
workbox.routing.registerRoute( | |
new RegExp('.(png|svg|jpg|jpeg)$'), | |
workbox.strategies.cacheFirst({ | |
cacheName: 'poc-cache-Images', | |
plugins: [ | |
new workbox.expiration.Plugin({ | |
maxAgeSeconds: 60 * 60 * 24 * 7, | |
maxEntries: 50, | |
purgeOnQuotaError: true, | |
}), | |
], | |
}), | |
); | |
workbox.routing.registerRoute( | |
new RegExp('https://randomuser.me/api/'), | |
workbox.strategies.staleWhileRevalidate({ | |
cacheName: 'poc-cache-employees', | |
cacheExpiration: { | |
maxAgeSeconds: 60 * 30, //cache the news content for 30mn | |
}, | |
}), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment