Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

feat: Implement offline cache for sw, and autoupdating (#431)

Matt Kilgore15e0cfb73f87
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",