From 15e0cfb73f8742e65e482be2efed97af5a182907 Mon Sep 17 00:00:00 2001 From: Matt Kilgore Date: Sat, 4 Jan 2025 10:28:01 -0500 Subject: [PATCH] feat: Implement offline cache for sw, and autoupdating (#431) --- frontend/nuxt.config.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index 91be9372..656ced40 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -25,7 +25,21 @@ export default defineNuxtConfig({ pwa: { workbox: { navigateFallbackDenylist: [/^\/api/], + cleanupOutdatedCaches: true, + runtimeCaching: [ + { + urlPattern: /^\/api/, + handler: "NetworkFirst", + method: "GET", + options: { + cacheName: "api-cache", + cacheableResponse: { statuses: [0, 200] }, + expiration: { maxAgeSeconds: 60 * 60 * 24 }, + }, + }, + ], }, + registerType: "autoUpdate", injectRegister: "script", injectManifest: { swSrc: "sw.js",