mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-13 09:28:50 +01:00
SWR cache /statuses/:id/context
This commit is contained in:
parent
fee37f9880
commit
a09f1ea1a3
1 changed files with 17 additions and 17 deletions
34
public/sw.js
34
public/sw.js
|
@ -46,20 +46,20 @@ const apiExtendedRoute = new RegExpRoute(
|
|||
);
|
||||
registerRoute(apiExtendedRoute);
|
||||
|
||||
// Not caching API requests, doesn't seem to be necessary fo now
|
||||
//
|
||||
// const apiRoute = new RegExpRoute(
|
||||
// /^https?:\/\/[^\/]+\/api\//,
|
||||
// new StaleWhileRevalidate({
|
||||
// cacheName: 'api',
|
||||
// plugins: [
|
||||
// new ExpirationPlugin({
|
||||
// maxAgeSeconds: 60, // 1 minute
|
||||
// }),
|
||||
// new CacheableResponsePlugin({
|
||||
// statuses: [0, 200],
|
||||
// }),
|
||||
// ],
|
||||
// }),
|
||||
// );
|
||||
// registerRoute(apiRoute);
|
||||
const apiRoute = new RegExpRoute(
|
||||
// Matches:
|
||||
// - statuses/:id/context - some contexts are really huge
|
||||
/^https?:\/\/[^\/]+\/api\/v\d+\/(statuses\/\d+\/context)/,
|
||||
new StaleWhileRevalidate({
|
||||
cacheName: 'api',
|
||||
plugins: [
|
||||
new ExpirationPlugin({
|
||||
maxAgeSeconds: 5 * 60, // 5 minutes
|
||||
}),
|
||||
new CacheableResponsePlugin({
|
||||
statuses: [0, 200],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
);
|
||||
registerRoute(apiRoute);
|
||||
|
|
Loading…
Reference in a new issue