Skip to content

Commit

Permalink
Workbox expiration plugin not working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Aug 4, 2024
1 parent ad7193d commit b3681a9
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,27 @@ const apiExtendedRoute = new RegExpRoute(
);
registerRoute(apiExtendedRoute);

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

const apiRoute = new RegExpRoute(
// Matches:
Expand Down

0 comments on commit b3681a9

Please sign in to comment.