-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces `IndexedDB` cache for parse results, keyed by file name and string contents (so every change in the file contents invalidates the parse cache). This greatly improves the >1st time load on every project. <video src="https://github.com/user-attachments/assets/faa3560b-81ca-4f1d-9d92-52526bf7f004"></video> Important points: 1. The cache is implemented in the worker level - to keep our current parse flow as identical to now as possible. If the feature flag is on, the worker tries to look for the file in the cache, compares the content - and if there is a cache hit it returns it from the cache instead of parsing it. 2. When a parsing does happen - if the feature flag is on, the parsed results are stored in the cache. 3. The cache is not project specific - allowing for cached results to be shared between projects (if the file name and contents are similar) 4. Currently arbitrary code (chunks of code we send as `code.tsx`) is not being cached, this can be controlled using a feature flag. 5. This PR also adds a settings pane for controlling cache behavior. The pane allows controlling the cache, the cache log and manually clear the cache if necessary. The cache settings toggle (with sound 🔉) : <video src="https://github.com/user-attachments/assets/a3c901c6-1b87-4013-a9ab-a2f531fb4457"></video> **Commit Details:** - The main logic changes are in `parser-printer-worker.ts` and `parse-cache-utils.worker.ts`. - The worker now gets a `parsingCacheOptions` argument, which controls whether or not to use the cache (and also logging) **Manual Tests:** I hereby swear that: - [X] I opened a hydrogen project and it loaded - [X] I could navigate to various routes in Preview mode Fixes #5659
- Loading branch information
Showing
15 changed files
with
515 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.