Skip to content

Fix issues with revalidateTag/revalidatePath #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 20, 2024

Conversation

conico974
Copy link
Contributor

  • Fix revalidateTag for next 15+
  • Fix revalidatePath not clearing the fetch cache ( When doing a revalidatePath('/whatever'), all the fetch or unstable_cache inside 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 start to take full advantage of DynamoDB.
In next start for 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 revalidatePath to 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 using revalidateTag and some custom tag )

Copy link

changeset-bot bot commented Jul 12, 2024

🦋 Changeset detected

Latest commit: 9463e64

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
open-next Patch
app-pages-router Patch
app-router Patch

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

Copy link

vercel bot commented Jul 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
open-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 19, 2024 8:49am

@sommeeeer
Copy link
Contributor

wow @conico974 did you really just fix this today aswell 👏

you are such an inspiration!

Copy link
Contributor

@khuezy khuezy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@conico974 conico974 merged commit b93034d into opennextjs:main Jul 20, 2024
3 checks passed
@conico974 conico974 deleted the fix/revalidate-tag branch October 29, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants