Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cache data locally #901

Merged
merged 2 commits into from
May 3, 2024
Merged

feat: cache data locally #901

merged 2 commits into from
May 3, 2024

Conversation

nikkothari22
Copy link
Member

SWR provides a way to use a custom cache provider. We now store the API calls in local storage as soon as the user reloads the page/exits the tab.

Example below with each API call throttled by 1 second:

Without cache (approx 12 seconds):
Export-1714739655557

With cache (near instant):
Export-1714739814425

The API calls are still being made - but since the results are cached, we're able to show the UI instantly. We still need to cache the APIs on the backend though.

Next steps:

  1. Avoid network request waterfalls (currently fetching users > channels > members > messages). We can remove all Context and reduce number of re-renders - just use SWR hooks directly and load everything in parallel.
  2. Avoid layout shifts when loading - remove all spinners and replace with perfectly sized skeleton loaders/boxes.

@nikkothari22 nikkothari22 merged commit 72eb260 into develop May 3, 2024
3 checks passed
@nikkothari22 nikkothari22 deleted the cahce-swr branch May 3, 2024 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant