Skip to content
Discussion options

You must be logged in to vote

Hey! I ran into the exact same issue when building my Vite portfolio. Coming from our uni Java projects, the whole static frontend thing takes a minute to get used to.

Since you don't have a backend, you basically have two clean ways to solve this, depending on what the API requires:

1. The pure frontend way: localStorage caching
If the API is public and doesn't need a secret token, just cache the data right in the browser!

  • How to do it: Fetch the data once, then use localStorage.setItem() to save the JSON and a timestamp. On the next page reload, check if the timestamp is older than, say, an hour. If not, just load the saved JSON.
  • Why it's great: It’s super fast, costs nothing, and comp…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Exoriy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Ask and answer questions about GitHub features and usage Programming Help Discussions around programming languages, open source and software development Welcome 🎉 Used to greet and highlight first-time discussion participants. Welcome to the community! source:ui Discussions created via Community GitHub templates
2 participants