Try use NetworkFirst, with 5s timeout

This commit is contained in:
Lim Chee Aun 2023-01-10 01:28:52 +08:00
parent c4bba6e507
commit 79ba6cdc29

View file

@ -1,7 +1,7 @@
import { CacheableResponsePlugin } from 'workbox-cacheable-response'; import { CacheableResponsePlugin } from 'workbox-cacheable-response';
import { ExpirationPlugin } from 'workbox-expiration'; import { ExpirationPlugin } from 'workbox-expiration';
import { RegExpRoute, registerRoute, Route } from 'workbox-routing'; 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; self.__WB_DISABLE_DEV_LOGS = true;
@ -50,8 +50,9 @@ const apiRoute = new RegExpRoute(
// Matches: // Matches:
// - statuses/:id/context - some contexts are really huge // - statuses/:id/context - some contexts are really huge
/^https?:\/\/[^\/]+\/api\/v\d+\/(statuses\/\d+\/context)/, /^https?:\/\/[^\/]+\/api\/v\d+\/(statuses\/\d+\/context)/,
new StaleWhileRevalidate({ new NetworkFirst({
cacheName: 'api', cacheName: 'api',
networkTimeoutSeconds: 5,
plugins: [ plugins: [
new ExpirationPlugin({ new ExpirationPlugin({
maxAgeSeconds: 5 * 60, // 5 minutes maxAgeSeconds: 5 * 60, // 5 minutes