From 79ba6cdc29f400a87a00498c4ffc285a5c4c6ec0 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 10 Jan 2023 01:28:52 +0800 Subject: [PATCH] Try use NetworkFirst, with 5s timeout --- public/sw.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/sw.js b/public/sw.js index 8bf163f..999e12c 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,7 +1,7 @@ import { CacheableResponsePlugin } from 'workbox-cacheable-response'; import { ExpirationPlugin } from 'workbox-expiration'; import { RegExpRoute, registerRoute, Route } from 'workbox-routing'; -import { CacheFirst, StaleWhileRevalidate } from 'workbox-strategies'; +import { CacheFirst, NetworkFirst } from 'workbox-strategies'; self.__WB_DISABLE_DEV_LOGS = true; @@ -50,8 +50,9 @@ const apiRoute = new RegExpRoute( // Matches: // - statuses/:id/context - some contexts are really huge /^https?:\/\/[^\/]+\/api\/v\d+\/(statuses\/\d+\/context)/, - new StaleWhileRevalidate({ + new NetworkFirst({ cacheName: 'api', + networkTimeoutSeconds: 5, plugins: [ new ExpirationPlugin({ maxAgeSeconds: 5 * 60, // 5 minutes