From 948d09d15b42b17d20acc159af53957eeb5fc464 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Fri, 4 Aug 2023 15:17:06 -0700 Subject: [PATCH 1/2] Update ISR revalidateTag handling --- .../src/server/lib/incremental-cache/file-system-cache.ts | 6 +++++- test/e2e/app-dir/app-static/app-static.test.ts | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/next/src/server/lib/incremental-cache/file-system-cache.ts b/packages/next/src/server/lib/incremental-cache/file-system-cache.ts index cc8c5c12fdf86..1fafd123a337c 100644 --- a/packages/next/src/server/lib/incremental-cache/file-system-cache.ts +++ b/packages/next/src/server/lib/incremental-cache/file-system-cache.ts @@ -255,8 +255,12 @@ export default class FileSystemCache implements CacheHandler { (data?.lastModified || Date.now()) ) }) + + // we trigger a blocking validation if an ISR page + // had a tag revalidated, if we want to be a background + // revalidation instead we return data.lastModified = -1 instead if (isStale) { - data.lastModified = -1 + data = undefined } } diff --git a/test/e2e/app-dir/app-static/app-static.test.ts b/test/e2e/app-dir/app-static/app-static.test.ts index aa83b42983d86..2df13917935cc 100644 --- a/test/e2e/app-dir/app-static/app-static.test.ts +++ b/test/e2e/app-dir/app-static/app-static.test.ts @@ -245,6 +245,11 @@ createNextDescribe( const newRes = await next.fetch( '/variable-revalidate/revalidate-360' ) + const cacheHeader = newRes.headers.get('x-nextjs-cache') + + if ((global as any).isNextStart && cacheHeader) { + expect(cacheHeader).toBe('MISS') + } const newHtml = await newRes.text() const new$ = cheerio.load(newHtml) const newLayoutData = new$('#layout-data').text() From 91094336f8fc7fe20a7fad3eebd52e89224fd21a Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Fri, 4 Aug 2023 16:02:48 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Zack Tanner --- .../next/src/server/lib/incremental-cache/file-system-cache.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/server/lib/incremental-cache/file-system-cache.ts b/packages/next/src/server/lib/incremental-cache/file-system-cache.ts index 1fafd123a337c..27743e72704da 100644 --- a/packages/next/src/server/lib/incremental-cache/file-system-cache.ts +++ b/packages/next/src/server/lib/incremental-cache/file-system-cache.ts @@ -258,7 +258,7 @@ export default class FileSystemCache implements CacheHandler { // we trigger a blocking validation if an ISR page // had a tag revalidated, if we want to be a background - // revalidation instead we return data.lastModified = -1 instead + // revalidation instead we return data.lastModified = -1 if (isStale) { data = undefined }