ServiceWorker: improve cacheMaps with better backend routes
This commit is contained in:
parent
05a2353fd6
commit
7636f8294f
|
@ -89,32 +89,33 @@ module.exports = merge(sharedConfig, {
|
||||||
minify: true,
|
minify: true,
|
||||||
},
|
},
|
||||||
cacheMaps: [{
|
cacheMaps: [{
|
||||||
match: requestUrl => {
|
// NOTE: This function gets stringified by OfflinePlugin, so don't try
|
||||||
|
// moving it anywhere else or making it depend on anything outside it!
|
||||||
|
match: ({ pathname }) => {
|
||||||
const backendRoutes = [
|
const backendRoutes = [
|
||||||
|
'/.well-known',
|
||||||
|
'/admin',
|
||||||
'/api',
|
'/api',
|
||||||
'/pleroma',
|
|
||||||
'/nodeinfo',
|
|
||||||
'/socket',
|
|
||||||
'/oauth',
|
|
||||||
'/.well-known/webfinger',
|
|
||||||
'/static',
|
|
||||||
'/instance',
|
'/instance',
|
||||||
'/main/ostatus',
|
'/main/ostatus',
|
||||||
|
'/manifest.json',
|
||||||
|
'/media',
|
||||||
|
'/nodeinfo',
|
||||||
|
'/oauth',
|
||||||
'/ostatus_subscribe',
|
'/ostatus_subscribe',
|
||||||
'/pghero',
|
'/pghero',
|
||||||
|
'/pleroma',
|
||||||
'/sidekiq',
|
'/sidekiq',
|
||||||
'/open-source',
|
'/socket',
|
||||||
|
'/static',
|
||||||
|
'/unsubscribe',
|
||||||
];
|
];
|
||||||
|
|
||||||
const isBackendRoute = ({ pathname }) => {
|
if (pathname) {
|
||||||
if (pathname) {
|
return backendRoutes.some(p => pathname.startsWith(p));
|
||||||
return backendRoutes.some(pathname.startsWith);
|
} else {
|
||||||
} else {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return isBackendRoute(requestUrl) && requestUrl;
|
|
||||||
},
|
},
|
||||||
requestTypes: ['navigate'],
|
requestTypes: ['navigate'],
|
||||||
}],
|
}],
|
||||||
|
|
Loading…
Reference in New Issue