Cache fetch request in localStorage

Hi there, I’m working on this side projects that make use of the GitHub API… So I’m going to multiple fetch requests to get the user repositories(the no & files), following (the no & each following profile), followers(the no & each followers profile). So I recently got aware of the github API rate limiting and how I could bump the rate limit to 5000 using my personal access token.

Since the project is entirely frontend, I don’t want to use the token since people can have access to it in the DOM or the network tab.

This is is why I think caching the request will be quite good for this project.

In the approach I tried, I couldn’t update new user info in the localStorage. The codepen is linked below:

https://codepen.io/Que0/pen/xxLpQzO

Local storage has a limited amount of space. I wouldn’t recommend using it for caching. Instead I would recommend using a client-side database.

https://github.com/jakearchibald/idb-keyval

I just implemented idb-keyval in my own project and found it super simple to set-up and use. Otherwise RxDB is a very robust, and powerful client-side database with a lot of flexibility but comes with a learning curve.

Hey there @windbeneathmywings , I will check this out but I hope I can message if I encounter any difficulty?

Learning JavaScript hasn’t been easy so far, kinda love + hate relationship

Hey @windbeneathmywings, I decided to give with idb-keyval but I do get data may be stale error in the indexDB panel. How do I tackle this?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.