From fb5d08a5545b522a945ae2c50958b489e473416f Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 2 May 2023 23:37:11 -0700 Subject: [PATCH] sw: use network first for index Signed-off-by: Varun Patil --- src/service-worker.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/service-worker.js b/src/service-worker.js index 530888b5..9d0ee17c 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -23,7 +23,15 @@ registerRoute( // strip certain headers such as HTTP-Range, which is required // for proper playback of videos. -const networkOnly = [/^.*\/apps\/memories\/api\/.*/]; +const networkOnly = [/^.*\/api\/.*/]; + +// Use network-first for memories page for initial state such as theming +registerRoute( + ({ url }) => url.origin === self.location.origin && url.pathname.endsWith('/apps/memories/'), + new NetworkFirst({ + cacheName: 'pages', + }) +); // Cache pages for same-origin requests only registerRoute(