-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: revalidation with file-system-cache (#58508)
### What? When using the file system cache with `isrMemoryCacheSize: 0`, time-based revalidation is not working, and the file is constantly updated. I have also added some debug logging to mirror that in the `fetch-cache` handler Detailed explanation in #58507 ### Why? The cached object's tags are incorrectly accessed, causing the cache to be rewritten every hit. This is catastrophic for a caching system that relies on file modification timestamps. The tags are one level up in the object from where [they are currently being accessed](https://github.com/vercel/next.js/blob/9ab8828f72e96f5de86a7c50b67a1c5abe6e146c/packages/next/src/server/lib/incremental-cache/file-system-cache.ts#L178). Below shows a cached fetch representation on disk. When written, the tags reside at `obj.tags` instead of `obj.data.tags` ```json { "kind": "FETCH", "data": { "headers": { "connection": "keep-alive", "content-encoding": "br", "content-type": "application/json; charset=utf-8", "date": "Wed, 15 Nov 2023 21:17:42 GMT", "server": "nginx/1.18.0 (Ubuntu)", "transfer-encoding": "chunked", "vary": "Accept-Encoding" }, "body": "[SNIP]", "status": 200, "url": "https://timeapi.io/api/Time/current/zone?timeZone=UTC" # this is where the current code is trying to pull the tags # "tags": [ "time-with-fetch" ] }, "revalidate": 20, # tags actually live here "tags": [ "time-with-fetch" ] } ``` Fixes #58507
- Loading branch information
Showing
3 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df4c2aa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stats from current release
Default Build
General Overall increase⚠️
Client Bundles (main, webpack)
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size
Middleware size
Next Runtimes
Diff details
Diff for page.js
Diff too large to display
Diff for edge-ssr.js
Diff too large to display
Diff for 199-HASH.js
Diff too large to display
Diff for main-HASH.js
Diff too large to display
Diff for app-page-exp..ntime.dev.js
Diff for app-page-exp..time.prod.js
Diff too large to display
Diff for app-page-tur..time.prod.js
Diff too large to display
Diff for app-page-tur..time.prod.js
Diff too large to display
Diff for app-page.runtime.dev.js
Diff for app-page.runtime.prod.js
Diff too large to display
Diff for server.runtime.prod.js
Diff too large to display