next.js
2ef787b1 - [devtools] Add a query parameter to restart endpoint to invalidate the persistent cache (#79425)

Commit
214 days ago
[devtools] Add a query parameter to restart endpoint to invalidate the persistent cache (#79425) Creates and passes through an option to turbopack to invalidate the cache. The dev overlay can then (not implemented) call this endpoint. Invalidation is performed by writing a marker file to disk, and then actually deleting the cache upon the next startup because: - Getting the database to drop all file handles is tricky. - You can't delete open files on Windows. - Writing an invalidation file is atomic, recursively deleting a directory is not. ### Testing Set up a small app with a large dependency (three.js). Ran the build, restarted the dev server, saw that the cached run was fast. Ran ``` curl -v --request POST --header "Content-Type: application/json" --data '{}' http://localhost:3000/__nextjs_restart_dev\?invalidatePersistentCache\= ``` And saw that the server restarted and the next page load was slow. ### Remaining Work (will come in subsequent PRs) In rough order of priority: - A separate endpoint to poll to see when the server is back up. - A webpack+rspack implementation. It looks like I can do a hack to forcibly change the webpack cache version, which should trigger similar behavior upon the next restart. - Passing a boolean to the dev overlay telling it if persistent caching is enabled or not. - The devtools UI implementation. - Telemetry. - A CLI subcommand that leverages this, so that you can do it from the terminal.
Author
bgw bgw
Parents
Loading