Currently, Cashtab updates the wallet every 10 seconds
- Cashtab makes an api call to retrieve the utxos set of the active wallet.
- If the utxos set has changed since last update, Cashtab will retrieve the latest 10 transactions of the active wallet.
- These 10 transactions will be shown in the Transaction History section
This approach has a few problem
- Transaction details will never change. When there is a new transaction, Cashtab should only retrieve
the new transaction from api server. The other 9 transactions are already stored in Cashtab,
we should not have to retrieve those details again from api server
- If we increase the number of transactions from 10 to say 100 (user should be able to view all the transactions),
we will likely reach the rate-limits imposed by the api server. Every 10s, Cashtab makes 100 api calls.
If these 100 api calls are completed before the next update, everything will be fine.
However, if it takes more than 10s, the next update will start and make another 100 api calls.
And it continues making another 100 api calls every 10s, causing rate-limits error. (adding a check
to make sure the next update will not run before the previous update has completed would fix this.)
This Diff adds caching with Service Worker to reduce the number of api calls that hit the api server.
With Service Worker and Caching
- we can potentially reduce the update cycle from 10s.
- add Push Notification