Safe to assume that local storage data doesn't change?
Application Type
Mobile

I am designing a form that needs to be available for offline usage. It depends heavily on data from a number of static entities that I use to populate some dropdowns; therefore, I have to cache these entities in local storage when the user logs into the application.

To increase performance, I check whether there is any data already stored in the local storage entity; if so, I skip the call to the Sync action for the entity. 

My question is; is there any scenario where there could be partial data loss in the local storage entities, so that there is data stored (and the sync with the server is skipped), but records may be missing, causing incomplete data to be displayed to the end user?

Also, if someone has any suggestions on another design solution to this, I would be very grateful. I'm not crazy about doing a huge number of server calls only to fetch static values, but I can't really think of another solution. 

Hello Johan Åström,

The next step you can take is to validate the count of records in the local storage entity matches with data from the server.

If the count doesn't match then you have to trigger the sync.

Hi Johan Åström,

you need to consider that for multiple reason sync could be interrupted in the middle, like losing network connection ..etc. you need to come up machanisem to ensure you have all the data you need locally. 


Wouldn't that simply roll back the entire sync, since the server actions run as transactions?

mvp_badge
MVP

Server database transaction do not apply to local storage entities. The.local storage does not support transactions.

it depend how you r handling the sync logic, can you share you oml here and we can have a look to the logic.

generally better you save locally when is the last sync happen or what is the last record sync when all records are saved in localstorage?  this of course is read only logic

@Daniël Kuhlmann ok! But if the network connection is lost in the middle of the call to the database (the server-side sync logic), no data at all would be returned rather than only a subset of data being returned and then persisted in the local storage, right?

@Noun Eltoum unfortunately, I can't share the oml as it's for a customer. But it's simply the auto-generated read-only sync actions that Outsystems creates.

mvp_badge
MVP

You need to understand and make your sync logic resiliant for the fact that if your server database transaction is rolled back due to an unexpected error, that your local storage data changes as part of that transaction are not automaically rolled back.

Hello Johan Åström,

The next step you can take is to validate the count of records in the local storage entity matches with data from the server.

If the count doesn't match then you have to trigger the sync.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.