next.js
a6223ac9 - fix(use-cache): remove awaiting revalidation (#92636)

Commit
143 days ago
fix(use-cache): remove awaiting revalidation (#92636) ### What? fixes #74882 The `use cache` directive does not revalidate in the background while serving (not expired) stale data. For the static pages, the whole page is blocked during revalidation, and fresh data is fetched served. While I don't agree with this, as it is just a duplication of the expire behaviour, this is documented as intended in the comments in the code. For the dynamic pages, when the data is flagged for revalidation, the stale data is blocked while fresh data is fetched. Once the fresh data is fetched, the function returns the stale data. On refreshing, the fresh data is served. This is the worst of both worlds, as we are still waiting for fresh data, and then seeing the stale data. In both cases there is no background revalidation of data, leading to slow, unresponsive pages. I have an example app showing this behaviour here: https://github.com/awo00/nextjs-use-cache-revalidate ### Why? In the `use-cache-wrapper`, the `generateCacheEntry()` function is awaited during revalidation which is blocking the stale data being returned. ### How? Removing the await allows the stale data to be returned faster. --------- Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
Author
Parents
Loading