From 7636f8294f99ccf4cae05aa4c28b0c1ce827d221 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Jun 2022 14:58:47 -0500 Subject: [PATCH 1/4] ServiceWorker: improve cacheMaps with better backend routes --- webpack/production.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/webpack/production.js b/webpack/production.js index c90decd4e..dc9954ff3 100644 --- a/webpack/production.js +++ b/webpack/production.js @@ -89,32 +89,33 @@ module.exports = merge(sharedConfig, { minify: true, }, 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 = [ + '/.well-known', + '/admin', '/api', - '/pleroma', - '/nodeinfo', - '/socket', - '/oauth', - '/.well-known/webfinger', - '/static', '/instance', '/main/ostatus', + '/manifest.json', + '/media', + '/nodeinfo', + '/oauth', '/ostatus_subscribe', '/pghero', + '/pleroma', '/sidekiq', - '/open-source', + '/socket', + '/static', + '/unsubscribe', ]; - const isBackendRoute = ({ pathname }) => { - if (pathname) { - return backendRoutes.some(pathname.startsWith); - } else { - return false; - } - }; - - return isBackendRoute(requestUrl) && requestUrl; + if (pathname) { + return backendRoutes.some(p => pathname.startsWith(p)); + } else { + return false; + } }, requestTypes: ['navigate'], }], From 5864b5a9835cef2870b2a3d64d3dc4df1db8d101 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Jun 2022 15:04:38 -0500 Subject: [PATCH 2/4] ServiceWorker: autoupdate every 1 hour --- webpack/production.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webpack/production.js b/webpack/production.js index dc9954ff3..9cec42468 100644 --- a/webpack/production.js +++ b/webpack/production.js @@ -29,6 +29,7 @@ module.exports = merge(sharedConfig, { logLevel: 'silent', }), new OfflinePlugin({ + autoUpdate: true, caches: { main: [':rest:'], additional: [ From 4b1c5eb0e82a8ad9b6a32afb8b72390d64102d22 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Jun 2022 15:08:07 -0500 Subject: [PATCH 3/4] ServiceWorker: make /auth a backend route --- webpack/production.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webpack/production.js b/webpack/production.js index 9cec42468..b2c98093b 100644 --- a/webpack/production.js +++ b/webpack/production.js @@ -97,6 +97,7 @@ module.exports = merge(sharedConfig, { '/.well-known', '/admin', '/api', + '/auth', '/instance', '/main/ostatus', '/manifest.json', From 0536f1e43a231d79ea602a042d38f540a4aed5e2 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 28 Jun 2022 15:18:05 -0500 Subject: [PATCH 4/4] ServiceWorker: p --> path --- webpack/production.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack/production.js b/webpack/production.js index b2c98093b..39ce1d663 100644 --- a/webpack/production.js +++ b/webpack/production.js @@ -114,7 +114,7 @@ module.exports = merge(sharedConfig, { ]; if (pathname) { - return backendRoutes.some(p => pathname.startsWith(p)); + return backendRoutes.some(path => pathname.startsWith(path)); } else { return false; }