Ajax refresh image

Ajax refresh image

  
I'm using the database image widget in a Screen. In this Screen I have a link to a popup where I can upload a new image. The process of recording, notifying the widget and refreshing the image is working fine.

But the browser caches the image and I have to mannually refresh it (Ctrl+F5) to get the new image shown.

Am I doing something wrong?
Nope.

I'm going to answer this, based what you are saying. refreshing should be working normally.
but if the browser is indeed caching the image, it's a simple matter of adding a timestamp/dynamic in the img-url.
thus something like image.jpg?ts=2362663
this will "force" the browser to notice the url has changes. It keeps caching the image,
but because the url has been changed after the refresh, it goes looking for the new image anyways.





J. ,

Just a quick question. Using the outsystems standard Image widget and it setting as a database image, I'm not being able to add to the image filename atribute something like "?"+IntegerToText(Minute(CurrDateTime()))+IntegerToText(Second(CurrDateTime())) because the ? character will be escaped to %3f.

Like João Melo asked, Am I doing something wrong?

Using a debugger and manually changing the %3f to ?, the ajax refresh works like a charm showing the new file uploaded via popup_upload.

Thanks in advance!
Hi,

I was also having the same problem with joão with the image source is from database. I have a rotate feature in which after the rotate action I invoke ajax refresh but it doesn't refresh the image. I need to press F5 to refresh the image and see the effect.

Thanks.
Hi,

You can try changing the filename of the image when saving it to the Database by appending some random chars to the end. I used Photo.Filename + GeneratePassword(10,True) which causes the browser to fetch the image every time you change it since the name changed, thus causing it to refresh.

Best regards,
Paulo

Hello,

I am facing this Ajax Refresh Image issue where the new uploaded picture did not refreshed on the page, but the record has been updated. If I save this updated record and reload the page (where it fetch the data from database through preparation action), the new uploaded picture is showed correctly.

On the image, I set to "No Cache". Filename is the filename of the picture. Filename of the new uploaded picture is different than the existing picture.

The Ajax Refresh just did not refresh the new picture. Anyone can help?

Lian Huat Wee wrote:

Hello,

I am facing this Ajax Refresh Image issue where the new uploaded picture did not refreshed on the page, but the record has been updated. If I save this updated record and reload the page (where it fetch the data from database through preparation action), the new uploaded picture is showed correctly.

On the image, I set to "No Cache". Filename is the filename of the picture. Filename of the new uploaded picture is different than the existing picture.

The Ajax Refresh just did not refresh the new picture. Anyone can help?


Attached with the test application.

Hi, browser will cache images based on file name.

When you uploading image you can get filename from Upload WIdget, save it to database along with binary, and then use stored filename in the image widget.

When you upload a different image (usually filename will be different), since the filename is changed, browser will not use cached image, but load the new image.

You can also randomize image filename instead of using original filename.

People, this thread is quite old already, don't ask new questions but start a new topic instead. Thanks!