perf(registry): cache discovery index responses - #1569
Open
ricardo-devis-agullo wants to merge 1 commit into
Open
perf(registry): cache discovery index responses#1569ricardo-devis-agullo wants to merge 1 commit into
ricardo-devis-agullo wants to merge 1 commit into
Conversation
GET / fanned out to repository.getComponent() for every component on every request and re-rendered the whole index view (incl. 1300-line CSS) per HTML hit. Cache built JSON/HTML discovery responses per registry instance, keyed by componentsList.lastEdit (via getComponentsDetails, which advances on publish/poll updates) plus the query variant (state/meta/theme/baseUrl/discovery flags, HTML vs JSON). A repeat hit costs one cheap lastEdit read and skips all getComponent calls and the view re-render. HTML-with-query bypasses the cache; JSON responses carry Cache-Control: public, max-age=<pollingInterval>. Tests: registry-routes-index-cache (11 specs: hit skips component fetches, lastEdit invalidation, variant isolation, Cache-Control, local/dev fallback). Full packages/oc suite: 1108 passing.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: GET / (packages/oc/src/registry/routes/index.ts) called repository.getComponent() for EVERY component on EVERY request, then re-rendered the whole index view (incl. 1300-line CSS) per HTML hit.
Fix:
Invalidation: lastEdit generation change drops the previous generation (also the memory bound); plus a 50-variant cap per generation.
Verify: