In Android I am caching some data returned from Rest api call. For cache data I want to update it only after data changed returned from Rest api call.
There two possible ways that I thing.
Problem: There are list of category I am getting from server and based on that I am setting tabs in android app. But this categories are less likely to change. I don't want tabs to wait to load until data received from server. That's why I using cache.
Please provide best implementation for this kind of case.
Ideally you would want to use a push notification from the server to let the app know that the tab structure has been updated and to fetch the new data. This allows you to piggyback on the socket already kept open.
A less ideal solution would be to cache the latest response and then, after the view is displayed, check the server to see if an update is present. Download the update and change the tabs when the update arrives.
You can do a check endpoint (against update_time, or whatever) every state change of the app, that way it's only a small amount of data being transferred unless the categories have changed.