Skip to content
Discussion options

You must be logged in to vote

When you have nested "use cache" directives in Next.js 15, each cache layer works independently with its own tags and scope.

In your example:

  1. Outer cache (getTodos with cacheTag("todos-${userId}")) - caches the entire result
  2. Inner caches (getTodo, getTodoStats with cacheTag("todo-${todoId}")) - cache individual queries

How it works:

  • If the outer cache is fresh, Next.js returns it immediately without calling the inner functions
  • If the outer cache is stale but inner caches are fresh, inner functions return cached data
  • When you call revalidatePath() or revalidateTag(), only the matching cache layers are invalidated

Your scenario with revalidatePath on createTodo/updateTodo:

  • If you only …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by onarbf
Comment options

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants