From c1be5adcb124aa0d7b88214a194742bdc76176ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 14 Oct 2024 13:00:42 +0200 Subject: [PATCH 1/4] fix(cache): overwrite also storage.cache to fs --- src/features.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/features.ts b/src/features.ts index c4ffe4a2..ceb74dbd 100644 --- a/src/features.ts +++ b/src/features.ts @@ -170,8 +170,9 @@ export async function setupCache(nuxt: Nuxt) { }) nuxt.hooks.hook('nitro:init', (nitro) => { nitro.hooks.hook('prerender:config', (config) => { + config.storage ||= {} config.devStorage ||= {} - config.devStorage.cache = { + config.storage.cache = config.devStorage.cache = { driver: 'fs', base: join(nuxt.options.rootDir, '.data/cache') } From 4d19e555a0203809bfa2b7ac05d841515f2507cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 14 Oct 2024 13:12:03 +0200 Subject: [PATCH 2/4] up --- src/features.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/features.ts b/src/features.ts index ceb74dbd..7f70ce28 100644 --- a/src/features.ts +++ b/src/features.ts @@ -158,21 +158,22 @@ export async function setupCache(nuxt: Nuxt) { storage: { cache: { driver, - binding: 'CACHE' + binding: 'CACHE', + base: 'cache' } }, devStorage: { cache: { driver, - binding: 'CACHE' + binding: 'CACHE', + base: 'cache' } } }) nuxt.hooks.hook('nitro:init', (nitro) => { nitro.hooks.hook('prerender:config', (config) => { - config.storage ||= {} config.devStorage ||= {} - config.storage.cache = config.devStorage.cache = { + config.devStorage.cache = { driver: 'fs', base: join(nuxt.options.rootDir, '.data/cache') } From 7584420d518373bd223280a4edb345fa66283848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 14 Oct 2024 13:21:22 +0200 Subject: [PATCH 3/4] chore: update devStorage based on dev option --- src/features.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/features.ts b/src/features.ts index 7f70ce28..a8b61bce 100644 --- a/src/features.ts +++ b/src/features.ts @@ -163,22 +163,20 @@ export async function setupCache(nuxt: Nuxt) { } }, devStorage: { - cache: { - driver, - binding: 'CACHE', - base: 'cache' - } + cache: nuxt.options.dev + // if local development, use KV binding so it respect TTL + ? { + driver, + binding: 'CACHE', + base: 'cache' + } + : { + // Used for pre-rendering + driver: 'fs', + base: join(nuxt.options.rootDir, '.data/cache') + } } }) - nuxt.hooks.hook('nitro:init', (nitro) => { - nitro.hooks.hook('prerender:config', (config) => { - config.devStorage ||= {} - config.devStorage.cache = { - driver: 'fs', - base: join(nuxt.options.rootDir, '.data/cache') - } - }) - }) // Add Server scanning addServerScanDir(resolve('./runtime/cache/server')) From 8614e8aff85fe839fbd6b22299d028c37a242a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 14 Oct 2024 13:25:28 +0200 Subject: [PATCH 4/4] remove base --- src/features.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/features.ts b/src/features.ts index a8b61bce..263eae8e 100644 --- a/src/features.ts +++ b/src/features.ts @@ -167,8 +167,7 @@ export async function setupCache(nuxt: Nuxt) { // if local development, use KV binding so it respect TTL ? { driver, - binding: 'CACHE', - base: 'cache' + binding: 'CACHE' } : { // Used for pre-rendering