Skip to content
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

Fix: 'force-dynamic' does not opt out of the data cache #75370

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

Tofugrass
Copy link

https://nextjs.org/docs/app/building-your-application/caching#segment-config-options

Setting fetchCache = 'default-no-store' opts out of the data cache.

I tested and confirmed this behavior live on my web app.

A page with dynamic = "force-dynamic" that uses unstable_cache will read the cached value (data cache) without calling the async fetcher function until the key has been invalidated (and purged).

The only difference 'force-dynamic' caused on my page was disable the full route cache, forcing the page to re-check the data cache. With tag-based invalidation, only the invalidated tags in the data cache had their fetch functions called.

i.e. 'force-dynamic' does not opt out of the data cache

https://nextjs.org/docs/app/building-your-application/caching#segment-config-options

Setting fetchCache = 'default-no-store' opts out of the data cache.

I tested and confirmed this behavior live on my web app. 

A page with dynamic = "force-dynamic" that uses unstable_cache will read the cached value (data cache) without calling the async fetcher function until the key has been invalidated (and purged). 

The only difference 'force-dynamic' caused on my page was disable the full route cache, forcing the page to re-check the data cache. With tag-based invalidation, only the invalidated tags in the data cache had their fetch functions called.

 i.e. 'force-dynamic' does not opt out of the data cache
@ijjk ijjk added the Documentation Related to Next.js' official documentation. label Jan 27, 2025
@ijjk
Copy link
Member

ijjk commented Jan 27, 2025

Allow CI Workflow Run

  • approve CI run for commit: c6c3ee7

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

1 similar comment
@ijjk
Copy link
Member

ijjk commented Jan 27, 2025

Allow CI Workflow Run

  • approve CI run for commit: c6c3ee7

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Related to Next.js' official documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants