Merge branch 'sw-autoupdate' into 'develop'
ServiceWorker: autoupdate every 1hr, revise backend routes See merge request soapbox-pub/soapbox-fe!1583
This commit is contained in:
commit
68fa74b3fc
1 changed files with 20 additions and 17 deletions
|
@ -29,6 +29,7 @@ module.exports = merge(sharedConfig, {
|
||||||
logLevel: 'silent',
|
logLevel: 'silent',
|
||||||
}),
|
}),
|
||||||
new OfflinePlugin({
|
new OfflinePlugin({
|
||||||
|
autoUpdate: true,
|
||||||
caches: {
|
caches: {
|
||||||
main: [':rest:'],
|
main: [':rest:'],
|
||||||
additional: [
|
additional: [
|
||||||
|
@ -89,32 +90,34 @@ 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',
|
'/auth',
|
||||||
'/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(path => pathname.startsWith(path));
|
||||||
return backendRoutes.some(pathname.startsWith);
|
} else {
|
||||||
} else {
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return isBackendRoute(requestUrl) && requestUrl;
|
|
||||||
},
|
},
|
||||||
requestTypes: ['navigate'],
|
requestTypes: ['navigate'],
|
||||||
}],
|
}],
|
||||||
|
|
Loading…
Reference in a new issue