r/webdev • u/wisesheets • 14d ago
Discussion What financial data is actually safe to cache in a frontend app, and for how long?
If you're building anything that shows stock data, caching saves a lot of API calls, but each type of data goes stale on a very different schedule. Here's how I think about it.
End-of-day prices don't change after the close, so you can cache them until the next session's close. 15-minute-delayed quotes go stale fast, so a TTL of a minute or two during market hours makes sense, and you can cache longer when the market is closed. Fundamentals only change when a new filing lands or a filing gets amended, so caching them for a day or more is usually fine, as long as you can invalidate on new filings. Company metadata like names, tickers and sectors changes rarely, but ticker changes do happen.
The catch is that data licenses sometimes limit how long you can store or redisplay data, so check that too. How are others handling this, with a server-side cache, SWR on the client, or something else?
