feat(perf): add client-side caching for dashboard API responses (#2436)#2470
Open
anuragbraveboy-sudo wants to merge 1 commit into
Open
feat(perf): add client-side caching for dashboard API responses (#2436)#2470anuragbraveboy-sudo wants to merge 1 commit into
anuragbraveboy-sudo wants to merge 1 commit into
Conversation
…ella-io#2436) - Intercept the global window.fetch in DashboardSyncProvider to implement client-side caching (stale-while-revalidate). - Configured configurable stale times per endpoint (5m for metrics, 1m for notifications, 2m default). - Support instant cache loading on navigation, background revalidation, and request deduplication. - Auto-invalidate cache on mutation requests (POST/PUT/DELETE/PATCH) or devtrack:sync events. - Safely bypass cache interception during tests (process.env.NODE_ENV === 'test'). - Update test/useUserSettings.test.tsx and test/weekly-digest-cron-auth.test.ts to support caching behavior.
GSSoC Label Checklist 🏷️@Umbrella-io — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
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.
Overview
This PR implements client-side caching for dashboard API responses to eliminate redundant fetches, minimize network overhead, and deliver instant layout navigation.
Closes #2436
Detailed Changes
src/components/DashboardHeader.tsx):window.fetchinside DashboardSyncProvider.devtrack:sync) are dispatched.process.env.NODE_ENV === "test") and returns early to prevent mock pollution in unit tests.test/useUserSettings.test.tsx: Updated mock assertions to properly expect a single mount-level fetch in the testing environment.test/weekly-digest-cron-auth.test.ts: Safely stubbed out the process-levelGITHUB_TOKENto empty during test runs, preventing live metrics fetches from polluting mock assertions.Verification Results
Verified that all modified tests and checks pass:
npm run type-check— Passednpx vitest run test/useUserSettings.test.tsx test/weekly-digest-cron-auth.test.ts— Passed (15/15 tests passed)