A flag to clear the fetch cache before the dev server starts #66583
dwjohnston
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
next dev
with a flag like--clearCache
and not have the cached data from the previous sessions exist. Fetch caching behaviour should still continue to occur.Non-Goals
Background
This has come up as part of an investigation of how next's caching behaviour works, and generally debugging how an application is behaving from a performance standpoint, comparing various tools/techniques as it relates to reducing API requests.
In the experiment I'm conducting I have an intentionally slow upstream API, and I want to demonstrate 'first load is slow, but subsequent ones are instant'.
Currently, cached requests from previous development sessions are persisted to disk, which means that we don't see the 'slow first load' functionality, which negates the scenario we're trying to demonstrate.
Our current work around is to remove the persisted files from disk before starting the server - we update our package script to:
Proposal
The very low hanging fruit is to just reproduce the workaround described above (or similar) in a flag for the dev command.
The problem with this solution is that it does require the developer to kill and restart the server whenever they need to clear the cache.
Potentially a smarter solution would clear the cache at sensible times, perhaps at file change (although that's probably too often?) or allow the developer to imperatively remove the cache (but how? With a CLI command?).
Beta Was this translation helpful? Give feedback.
All reactions