Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
purgeOnQuotaError = assetCachingOption.purgeOnQuotaError;
}
const cachingConfig = {
cacheName: AMP_ASSET_CACHE,
plugins: [
new AssetCachingPlugin({
maxEntries: assetCachingOption.maxEntries || 25,
denyList: assetCachingOption.denyList,
purgeOnQuotaError,
}),
],
};
switch (assetCachingOption.cachingStrategy) {
case 'NETWORK_FIRST':
cachingStrategy = new NetworkFirst(cachingConfig);
break;
case 'STALE_WHILE_REVALIDATE':
cachingStrategy = new StaleWhileRevalidate(cachingConfig);
break;
default:
cachingStrategy = new CacheFirst(cachingConfig);
break;
}
router.registerRoute(assetCachingOption.regexp, cachingStrategy);
});
}
import {precacheAndRoute} from 'workbox-precaching';
import {NetworkFirst} from 'workbox-strategies';
import {registerRoute} from 'workbox-routing';
precacheAndRoute(self.__WB_MANIFEST);
addEventListener("message", event => {
if (event.data && event.data.type === "SKIP_WAITING") {
skipWaiting();
}
});
registerRoute(
({url}) => url.pathname === '/',
new NetworkFirst()
);
registerRoute(
({url}) => url.pathname.startsWith('/message'),
new NetworkFirst()
);
registerRoute(
({url}) => url.pathname.startsWith('/request'),
new NetworkFirst()
);
registerRoute(
({url}) => url.pathname.startsWith('/members'),
new NetworkFirst()
);