Skip to content

Conversation

@vas3a
Copy link
Collaborator

@vas3a vas3a commented Oct 26, 2022

https://topcoder.atlassian.net/browse/TCA-590

Uses swr package to make the fetching requests for the learn tool.

  • This ensures data is readily available on subsequent calls and it will be fetched in the background.
  • It uses a localStorage caching for data that doesn't change too much (eg. all certificates listing, courses, lessons) so they are available on hard reloads as well.
  • This doesn't affect the initial loading speeds (other than deduplicating calls), but improves the overall app responsiveness after the first use

@vas3a vas3a self-assigned this Oct 26, 2022
Copy link
Contributor

@testflyjets testflyjets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks great but it's not clear to me what the mechanism is to invalidate the client-side data caches if we update data in DynamoDB. Can you clarify that for me?

Copy link
Contributor

@brooketopcoder brooketopcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I am also curious about how the cache is invalidated. Is it related to the revalidateInMount config option? What mechanism does it use to revalidate? Does it just make the call again in the bg?

https://swr.vercel.app/docs/options

https://swr.vercel.app/docs/revalidation

@testflyjets
Copy link
Contributor

This all looks great but it's not clear to me what the mechanism is to invalidate the client-side data caches if we update data in DynamoDB. Can you clarify that for me?

Ah, I think I get it -- SWR == "stale while refreshing" -- the cached data is provided while fresh data is retrieved in the background. All good.

@vas3a
Copy link
Collaborator Author

vas3a commented Oct 26, 2022

Hey @testflyjets @brooketopcoder ! Yeah, the cached data is served while the new data is fetched in the background.

@vas3a vas3a merged commit 5243a7b into TCA-586_page-load-improvements Oct 28, 2022
@vas3a vas3a deleted the TCA-590_use-swr-for-data-fetching-in-learn branch October 28, 2022 15:54
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.

4 participants