Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { registerRoute } from 'workbox-routing'
import {
CacheFirst,
StaleWhileRevalidate,
NetworkOnly,
} from 'workbox-strategies'
import { ExpirationPlugin } from 'workbox-expiration'
const oneWeek = 7 * 24 * 3600
if (process.env.NODE_ENV === 'development') {
registerRoute(/\.js/, new NetworkOnly())
registerRoute(/\.css/, new NetworkOnly())
}
//#region Pictures
registerRoute(
/\/preview\/\d+/,
new CacheFirst({
cacheName: 'texture-preview-v2',
fetchOptions: {
credentials: 'omit',
},
plugins: [
new ExpirationPlugin({ maxAgeSeconds: oneWeek, purgeOnQuotaError: true }),
],
}),
)