Hey everyone! I'm developing a chat app, and I've noticed that my database reads and writes are becoming pretty expensive. I'm interested in implementing some caching, but I have concerns about potential synchronization problems.
I came across IndexedDB for client-side caching, but I've read that it can behave unpredictably, especially on Safari. Unfortunately, it doesn't seem to address the sync issue either. I'd appreciate any beginner-friendly advice on effective caching strategies. Thanks a lot! 🙂
3 Answers
Hey, what’s this drama with Redis that you mentioned? I’m a bit out of the loop.
Totally second the recommendation for Valkey! It’s great for websocket pub/sub, plus it has a circular buffer for channel state. This means your database only needs to persist logs for scrolling through chat history. Just keep in mind to have a plan for expiring entries if your chat rooms stick around for a while.
It sounds like you're likely using a managed database, which can get pricey. Instead of caching on the client side, consider adding a server-side cache layer where your app is deployed. Redis used to be the go-to for simple apps, but given the recent licensing issues, you might want to look at alternatives like Valkey. It's been a solid choice for many developers.
Related Questions
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads