Goodmorning!
My application uses a database request to get items for its navigation that needs to be loaded on every page request.
Although the request is a very simple query, I worry about the overall performance a little. Would it be better to cache this or should I not worry about a simple query?
Is some kind of caching is the way to go, can someone point me in the right direction on how to do this (with wappler)?
Also the same kind of problem with notifications in my app; every user can have a or a few notifications. This must be checked in the database and shown on every page...
Is there an easy cache solution for this without having to check it on every page?
The notifications are visible like in any other app as a numer of notifications in a red circle in the navigation bar over some bell-icon (think whatsapp or any other app)
When the user clicks the bell-icon a dropdown displays the titles of the unread notifications.
ok, then you can cache the same way, I guess there is a server action that makes it read onclick or something and on success you reload the notifications. At that step make sure you check the reload checkbox, so when the notification action runs again it is not coming from cache.
Your concern is valid but I think you shouldn't worry about it yet. There's only one ideal solution (in my opinion), and that's caching the Database Query steps. The Database Query steps have no built-in option for cache, and there's no separate Cache step/group which you could put a Database Query inside. So, your ideal cache solution doesn't exist yet. If you ever reach the point where you need to scale the app then you'll either:
Horizontally scale the database server with e.g. read-only replicas
Write (or hire someone to do) a custom Wappler extension to Cache database queries
You do have a middle-ground solution right now, that's the Wappler Redis custom extension that allows you to GET/SET data in Redis, so you could implement some logic to retrieve data from Redis first, and if the data is not present then you perform the database query and save the data into Redis. But I'm guessing you're a beginner, in my opinion you don't need that kind of overhead right now, you just need to be aware in case you need it later.