Unverified Commit e4aecabc authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update ISR revalidateTag handling (#53595)

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: https://github.com/vercel/next.js/issues/53187
parent acf5e845
...@@ -255,8 +255,12 @@ export default class FileSystemCache implements CacheHandler { ...@@ -255,8 +255,12 @@ export default class FileSystemCache implements CacheHandler {
(data?.lastModified || Date.now()) (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) { if (isStale) {
data.lastModified = -1 data = undefined
} }
} }
......
...@@ -245,6 +245,11 @@ createNextDescribe( ...@@ -245,6 +245,11 @@ createNextDescribe(
const newRes = await next.fetch( const newRes = await next.fetch(
'/variable-revalidate/revalidate-360' '/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 newHtml = await newRes.text()
const new$ = cheerio.load(newHtml) const new$ = cheerio.load(newHtml)
const newLayoutData = new$('#layout-data').text() const newLayoutData = new$('#layout-data').text()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment