depapp / IndoGitHubers

IndoGitHubers is an application that displays the GitHub rank of users in Indonesia.
https://indogithubers.com
73 stars 18 forks source link

[🙏] Cache API per day #28

Closed mazipan closed 17 hours ago

mazipan commented 5 days ago

Since the data source is updated in the daily basis, it's unnecessary to always fetch it in every page load.

Consider to cache it with expiry 1 day, so we will refetch in another day.

Namchee commented 1 day ago

Hi, I'm interested in contributing for this feature. Do we have any preferences on where the cache should be stored?

Personally, I think browser cache with only-if-cached and checking the result is enough for this.

Or we could leverage SWR's provider by using localStorage

mazipan commented 1 day ago

I do prefer localStorage, but since localStorage doesn't have expiry, you might need to add logic extension to check the expiry time.

Ideally it only store for the same day, since in the next day we will generate new data so client might need to refetch to get the last updated data.