Skip to content

Commit

Permalink
Update ISR revalidateTag handling (#53595)
Browse files Browse the repository at this point in the history
This ensures `revalidateTag()` doesn't cause an async/background revalidation unexpectedly and instead does a blocking revalidate so fresh data is shown right away when a path is using ISR. 

Test deployment with patch can be seen here: https://next-revalidation-test-47rqf8q5s-vtest314-ijjk-testing.vercel.app/

Fixes: #53187
  • Loading branch information
ijjk authored Aug 4, 2023
1 parent acf5e84 commit e4aecab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
if (isStale) {
data.lastModified = -1
data = undefined
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/e2e/app-dir/app-static/app-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e4aecab

Please sign in to comment.