Skip to content

n the Next.js App Router, how does data fetching using the native fetch API behave, particularly concerning its built-in Data Cache? #81245

Answered by SoumyaEXE
Dronzer2code asked this question in Help
Discussion options

You must be logged in to vote

By default, fetch requests in Server Components are cached on the server (“Data Cache”).

On the first request, Next.js fetches data from the remote source and stores it in the Data Cache.

Subsequent requests for the same resource will return the cached data, as long as it’s still fresh.

If the cache is stale or missing, Next.js fetches new data and updates the cache.

You can control caching per request with the cache option:

cache: 'force-cache' (default): Uses the Data Cache if possible.

cache: 'no-store': Always fetches fresh data and does not cache the response.

Revalidation:

You can set a next.revalidate option to specify how often cached data should be considered stale and refetched.

T…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Dronzer2code
Comment options

Answer selected by Dronzer2code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants