43
Views
5
Comments
Reactive: cache static entities in local storage
Discussion

I often use static entities to store labels, statuses and more.

In order to show them on screen, they are fetched from the server several times at different screens, sometimes all records to be selected in a filter, or sometimes one record to fetch attributes such as color, description etc.

Why fetch them so many times when they are static? A waste of server and database capacity and roundtrips.

In Mobile we have local storage entities to sync such data.

In Reactive we do not have access to local storage out of the box. There is a forge component (Local Storage) that allows us to store key-text value pairs.

I could use that to cache static entities as JSON. Not ideal but there are no server requests anymore.

But how do I know when to update the cache when the static entity is updated (or when a new client application is installed). Of course it can be updated on every OnApplicationReady but it would be better to update it only when the application is updated. How do I know when that happens? Should I check the Application manifest in the local storage?

Does anybody have a nice solution to cache static entities?

2022-07-12 01-10-14
Jithu Cheriath Thomas

Hi @Rogier Olde Dubbelink ,

I think its good to use client variables in reactive application if data is,

  • Session-Specific Data:

    • If the cached data is user-specific and needs to persist throughout a session (e.g., UI preferences, filters).
  • Small Data Size:

    • If the cached data is lightweight, such as a few strings, numbers, or small JSON objects.
  • Performance Optimization:

    • When frequently accessed data is needed to reduce API calls and improve page performance.
  • Non-Sensitive Information:

    • If the cached data does not contain confidential or sensitive information (e.g., non-sensitive user settings).

I hope it helps,


Thanks,

Jithu Thomas

2024-12-02 13-16-47
Vipin Yadav

Hi @Rogier Olde Dubbelink,

To efficiently cache static entities in Reactive applications, you can use a combination of local storage and versioning:

Cache Static Data: Use the Local Storage Forge component to store static entity data as JSON.

Track Application Updates: Save the application's version or a static entity timestamp in local storage.

Update Cache on Changes: Compare the stored version/timestamp with the current application version or a unique static entity identifier.

OnApplicationReady: If a mismatch is detected, fetch the latest data from the server and update the cache.

This ensures minimal server calls while keeping the cache updated.

Thanks,

Vipin Yadav


2020-09-04 11-39-50
Rogier Olde Dubbelink

Thank you Vipin!

Then we are on the same page. Question remains:

Track Application Updates: Save the application's version or a static entity timestamp in local storage.

How do I know determine the current application version? 

Best regards,

Rogier

2021-11-12 04-59-31
Manikandan Sambasivam

Hi @Rogier Olde Dubbelink,

Please check the below link

https://www.outsystems.com/forums/discussion/74061/how-can-i-dynamically-get-the-version-number-of-my-application-to-show-inside-my/

2022-12-30 07-28-09
Navneet Garg

I think we can use a Site Properties which can easily manage from service center and create logic accordingly to update the static entities in local storage.


There are couple of forge component for getting application version but bit complicated. I will prefer timestamp or Site Properties to track updates

https://www.outsystems.com/forge/component-overview/12301/application-version-information-o11


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