Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ISR page re-rendering after revalidate expiry
* As outlined in vercel#24806 I there's currently a bug with the incremental static regeneration (ISR) logic incorrectly prolonging the life of rendered page content when it's the `LRUCache` is refreshed with potentially stale content from the filesystem cache. * This because if a page is not present in the `LRUCache`, but is present in the filesystem cache then it's re-added to the `LRUCache` with a fresh cache expiry calculated from the current time using the `revalidate` window. * If that page continues to be pushed out of the LRUCache before the next request comes in after the revalidation window expires then this creates an endless loop of the same stale content from the filesystem being served, without it being regenerated. * This fix addresses that issue by adding a `fromTime` argument to the revalidation period calculation, so that when we're falling back to the filesystem we can use the filesystem's `lastModfied` timestamp for that file to anchor the revalidation calculation, rather than restarting from the current time in every case. * That means that if page content from the filesystem is stale it will be marked as so when returned from the incremental cache `get` method (`isStale: true`), which tells next server to regenerate the page in the background. * If however the the page content from the filesystem is still within the revalidate window (i.e. is not yet stale) then it will be added back to the LRUCache with the correct remaining duration for the `revalidateAfter`. Fixes vercel#24806
- Loading branch information