Fix issues with revalidateTag/revalidatePath#470
Merged
conico974 merged 7 commits intoopennextjs:mainfrom Jul 20, 2024
Merged
Conversation
🦋 Changeset detectedLatest commit: 9463e64 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Collaborator
|
wow @conico974 did you really just fix this today aswell 👏 you are such an inspiration! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
revalidateTagfor next 15+revalidatePathnot clearing the fetch cache ( When doing arevalidatePath('/whatever'), all thefetchorunstable_cacheinside this route would return the cached value instead of refetching )There is a few things that we need to think about:
Right now the fetch cache in OpenNext works in a different way than in
next startto take full advantage of DynamoDB.In
next startfor every get to the incremental cache, they check for every tag used in this get ( and this include layout, page and fetch cache tags ), we only check given the path which entry in DDB is newer, and if so consider the cache entry stale. This mean we can make one single optimized query to DDB instead of either multiple get or an expensive scan/query.On the other hand the current DDB solution requires a lot more write than the default cache included in next ( They only write on
revalidateTag)I think in the future we should probably support the 2 type of cache ( The next cache could be easily implemented in SQL for example, and it's way better to do it that way in SQL than the DDB way ). Even in DDB, someone barely using on demand revalidation would benefit from a next type of cache.
The other thing is, we may want to allow the
revalidatePathto not clear the fetch cache, this gives a lot more flexibility and would allow to invalidate only what's really needed ( But that's not how next works right now ). Not sure if that's something that people may want. We could introduce an env variable that if set would make it work like right now ( it's still possible to clear the fetch cache individually usingrevalidateTagand some custom tag )