Repository navigation
Cache Inspector panel in Next.js DevTools: see why data is cached, stale, or dynamic #99635
Replies: 1 comment
|
This is a useful direction, and Phase 1 in particular is well scoped. Being able to answer "is this Open questions1. Does the dev server already track enough metadata?
2. Should it be data, not just a panel? 3. Should it be gated behind Cache Components? Phase 2: reasons for dynamic renderingThis is the hardest part, and the phrase "linking to the exact source location" needs a clear definition. A route is usually dynamic for several reasons at once:
Source locations need source maps in the dev server, and they can be wrong after compilation or inside shared packages. Treat them as best-effort and show the module path as a fallback. Phase 3: revalidation log and Invalidate buttonTwo concerns:
Smaller notes
I'd support starting Phase 1 with the metadata checks above, then writing a short design note for Phase 2 before implementation, since the source-location part depends on details that are easier to settle on paper. |
Uh oh!
There was an error while loading. Please reload this page.
Goals
next devto see which cache entries (use cachefunctions, cached segments) are used on the current route, with HIT/MISS status, tags, and cacheLife profile.cookies()atapp/dashboard/page.tsx:14").revalidateTag/updateTagcall invalidated which entry, and from where) to make "why is this data stale?" debuggable.Non-Goals
next dev.Background
Caching is one of the most common sources of confusion in the App Router. Questions like "why is this page showing stale data after
revalidateTag?", "is thisuse cachefunction actually hit or re-executed every request?", and "why did this route become dynamic?" come up often, and today the answers are spread across build output, server logs, config options and trial and error.Current alternatives and prior art:**
This proposal aims to complement these tools, not replace them.
Proposal
A new Cache Inspector panel in the existing Next.js DevTools, available only in
next dev.For the current route it lists entries like:
getUser(id)use cacheuser,user:123minutesgetPosts()use cachepostshours/dashboardsegmentSelecting an entry shows its source location (clickable to open in editor), the reason it is dynamic when applicable, its revalidation history, and a dev-only "Invalidate" button.
Incremental scope:
use cacheentries on the current route with HIT/MISS, tags and cacheLife.Phase 1 alone would already answer the most frequent questions.
Open questions:
I'd be happy to work on Phase 1 if the team thinks this direction makes sense, and to adjust the design based on feedback before writing code.
All reactions