I am using Image Widget in Reactive Web App to display Image with type Binary Data from Database on screen.
I noticed that Cache property in Traditional Web Image Widget is no longer used in Reactive Web App Image Widget.
Is there any way to do caching setting similar to Traditional Web Image Widget in Reactive Web App.
Hello @Ha Duc Phuoc,
I noticed that the Image widget doesn’t have a caching property, but there’s a workaround for this. Since you’re retrieving the image from the backend, you can use the Cache in Minutes property on the Aggregate itself.
Alternatively, if you’re using a Server Action to retrieve the image, you can also apply caching there. Just make sure you’re following best practices for storing binary data in the backend for example, store binary content in a separate entity rather than mixing it with other related attributes in the same entity. This helps improve performance and maintainability.
Thanks for your guide.
I noticed that to use the Aggregate cache, you need to use Aggregate in Server/Data Action.
When setting the Cache property in the Image Widget of Traditional Web, the binary data of the image will be saved in the backend, right? If so, I think it is possible to do it the way you suggested.
Exactly they are the same mechanism but different implementation considering it is Traditional or Reactive.
Hi
If your image comes from binary data in the database (e.g., via a REST or aggregate), the best way to control caching is to add a cache-busting query string to the image URL.
Example:
"data:image/png;base64," + BinaryToBase64(GetImageById.ImageBinary) + "?v=" + IntegerToText(GetImageById.ImageId)
Hi @Ha Duc Phuoc
When caching is set for a Server Action or Aggregate in OutSystems, the platform first fetches and stores the data in cache for the specified duration or as long as the input parameters remain unchanged. The next time the action or aggregate is called with the same input, OutSystems returns the cached data instead of fetching from the database, supporting high performance and reduced server load.
Binary Data and Caching
If the requirement is to cache binary data (such as files or images), OutSystems supports caching Server Actions returning binary outputs.
On first call, the binary data is retrieved from the database and stored in cache; subsequent calls with the same parameters fetch cached data until the cache expires or the parameters change.
This means the binary file will not be re-read from the database each time until cache timeout or invalidation, aligning with your need for efficient repeat access.
Cache Invalidation and Timeout
Cache is invalidated if parameters change, cache duration expires, or module/site property changes occur.
If the binary data is edited or the cache timeout is reached, a fresh database fetch occurs on the next access.
Caching binary data works just as with other data types, improving application performance and reducing unnecessary database load while maintaining validity and freshness based on parameters and timeout settings
Thanks
Md Mansur