Skip to content

feat: add stale-while-revalidate to investor portfolio query - #50

Open
Stephan-Thomas wants to merge 1 commit into
StellarState:devfrom
Stephan-Thomas:issue-34
Open

feat: add stale-while-revalidate to investor portfolio query#50
Stephan-Thomas wants to merge 1 commit into
StellarState:devfrom
Stephan-Thomas:issue-34

Conversation

@Stephan-Thomas

Copy link
Copy Markdown

Description

Adds stale-while-revalidate caching to the investor portfolio query to improve repeat-visit performance. Portfolio data is considered fresh for 60 seconds, allowing previously fetched positions to be displayed immediately while a background refetch keeps the data up to date. The cache is invalidated after a successful investment so users always see their latest portfolio.

Closes #34

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • ♻️ Code refactoring
  • ✅ Test addition or update
  • 🔧 Configuration change

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Testing

How to Test

  1. Open the investor portfolio page and allow the initial query to complete.
  2. Navigate away and return within 60 seconds; verify the cached portfolio is displayed immediately without the loading spinner.
  3. Observe the Refreshing… indicator while the background revalidation request is in progress.
  4. Complete a new investment and verify the portfolio query is invalidated and refreshed with the updated positions.
  5. Wait longer than 60 seconds before revisiting the portfolio page and verify a fresh request is made instead of serving stale cached data.

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • E2E tests added/updated (if applicable)
  • Manual testing completed

Screenshots (if applicable)

Included in the PR:

  • Before/after comparison of repeat portfolio visits.
  • Screenshot showing cached portfolio rendering immediately.
  • Screenshot of the subtle Refreshing… indicator during background revalidation.
  • Screenshot demonstrating the refreshed portfolio after a successful investment.

Additional Notes

  • Configured the investor portfolio query with a 60-second staleTime.
  • Uses stale-while-revalidate behavior to improve perceived performance without sacrificing data freshness.
  • Cache is explicitly invalidated after a confirmed investment to ensure newly created positions appear immediately.

For Reviewers

  • Code quality and readability
  • Test coverage
  • Security implications
  • Performance impact
  • Breaking changes

@drips-wave

drips-wave Bot commented Aug 1, 2026

Copy link
Copy Markdown

@Stephan-Thomas Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add stale-while-revalidate caching to the investor portfolio query for instant repeat visits

1 participant