Workbox expiration plugin not working as expected

This commit is contained in:
Lim Chee Aun 2024-08-04 18:05:03 +08:00
parent ad7193d067
commit b3681a93ee

View file

@ -96,24 +96,27 @@ const apiExtendedRoute = new RegExpRoute(
); );
registerRoute(apiExtendedRoute); registerRoute(apiExtendedRoute);
const apiIntermediateRoute = new RegExpRoute( // Note: expiration is not working as expected
// Matches: // https://github.com/GoogleChrome/workbox/issues/3316
// - trends/* //
// - timelines/link // const apiIntermediateRoute = new RegExpRoute(
/^https?:\/\/[^\/]+\/api\/v\d+\/(trends|timelines\/link)/, // // Matches:
new StaleWhileRevalidate({ // // - trends/*
cacheName: 'api-intermediate', // // - timelines/link
plugins: [ // /^https?:\/\/[^\/]+\/api\/v\d+\/(trends|timelines\/link)/,
new ExpirationPlugin({ // new StaleWhileRevalidate({
maxAgeSeconds: 1 * 60, // 1min // cacheName: 'api-intermediate',
}), // plugins: [
new CacheableResponsePlugin({ // new ExpirationPlugin({
statuses: [0, 200], // maxAgeSeconds: 1 * 60, // 1min
}), // }),
], // new CacheableResponsePlugin({
}), // statuses: [0, 200],
); // }),
registerRoute(apiIntermediateRoute); // ],
// }),
// );
// registerRoute(apiIntermediateRoute);
const apiRoute = new RegExpRoute( const apiRoute = new RegExpRoute(
// Matches: // Matches: