Best Practice for online data from API

I was asking to build an app for a customer, it is basically a restaurant guide he owns and run on the web that he want to be available on mobile phone with some peculiar characteristics (like ‘save to favorites’, ‘navigate to restaurant’ ‘reastaurants around me’ and so on); the guide is really small, they are about 120 restaurants with data like name, map address, description, main image, gallery of images, region and so on, every document can be accessed via API, average size of every document is about 30K not considering the attachments. The app will also support a news section still coming from API
Due to the fact that restaurants documents won’t change often during time and sometimes the API is really slow, i was thinking to download all the restaurant data (except images) at first startup of app, and maybe expose an API method to check if data need to be refreshed. This way the app is available offline (News will be online only, but its irrelevant), even if without images, and API latency is avoided.
I was wondering if this could be a good approach (download about 4Mb of data on startup and store on the user phone) or maybe it’s better a full online experience, or a in-between solution like storing the data on the phone (including photos) first time a document is accessed (and have his cache expire after a X time)

Any suggestion will be appreciated
Thank you

I think it makes sense to cache them, but the details of how much to cache, when to do it, when and how to expire the entries etc. depend on your requirements. I think that’s why they say that cache invalidation is one of the hard problems in Computer Science.

I think, probably the best you can do is picking something that seems reasonable and see how it works out.

I think I would probably download on request and cache them for a reasonable amount of time. If the user wants to load the info again, make a request with an If-Modified-Since header. Depending on the response you either use the cached version or download the updated version.
But if you do not get a response in, say, 2 seconds, just use the cached version. If you fall back to the cached version you could potentially indicate to the user that the info is cached and could be out of date.

If there’s some way to predict that the user might click on a particular entry you could download it in anticipation.

I have not tried somethinklg like the above myself.

Thank you for your suggestion, i usually grab live data when dealing with it, but in this case my concern is about latency and the fact that this app, being a sort of touristic guide, should work offline too (maybe, since that navigation and maps wont be available in any case). My main concern about caching and storing local data is about size onnthe phone, are there some limitations or suggestions? what if the phone have no space (i revert to live data i guess), maybe a progressive download could be the solution, storing requested data and predict next requests (this is not a big deal, since i can download things based on physical location or things that are located nearby a search).
Im pretty sure that data have long lifespan (besides the news, but these are not vital, of course neither the rest is vital) and i know what and when there is an update, so ill try some solution, my goal is that the user will have a smooth experience. Also if i have all the data on the phone it would be easier and faster, for example, having a real time search

thanks again for your suggestions!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.