2

After getting the response from the server if the same network call was called again instead of showing the progress bar we can persist the previous result until the response comes. So I wanted to know which is a better approach is it to store in database or cache the response using http result cache. Say the data can be acted upon until the newer response comes back and which is widely used, any suggestions can be appreciated

Aniruddha K.M
  • 7,361
  • 3
  • 43
  • 52

1 Answers1

1

Depends on what your use case is. Typically I try to keep it stupidly simple (KISS). Don't use a database unless you have a reason to such as needing to query data or do complex aggregates. Caching the http result or just dumping objects to disk is sufficient for most typical use cases.

FriendlyMikhail
  • 2,857
  • 23
  • 39
  • 1
    I would also say that persisting the data works better for me than storing it in cache if you want your app to work offline. Like if you have a feed of objects presented in your android app, you would want to engage the user even if he/she is offline so they will keep on using your app when they go through a tunnel / go on a long plane ride etc. – Simon Oct 16 '15 at 19:12
  • Sure but that does not mean that disk storage necessarily needs to be SQL. – FriendlyMikhail Oct 16 '15 at 19:13
  • But cache is so temporary and will be destroyed when and if the android system needs the memory. I think first-prize is always SQLite, second is cache. – Simon Oct 16 '15 at 19:18
  • you are talking about in memory cache. You can cache on disk as well. DiskLRU cache is one implementation of a on disk cache. – FriendlyMikhail Oct 16 '15 at 19:19