B4J Question WebApp: Is it possible to clear browser data via b4j app?

Mashiane

Expert
Licensed User
Longtime User
Can you give an example of the data you like to clear?

If it is possible with JavaScript then you can use ws.Eval to run it.
Actually what I want to do is optionally clear the cache of my abmaterial webapp. Why?

I had replaced some images in my app for use however each time I was testing my app, the old images kept on showing even though in the folder the new pngs were replaced. These images are used during run time for some displays using ABMImage components. So after I cleared the cache, the new images started working.

Looking deeper into the scavenge module, there is a call ABM.ScavengeCache(ABMShared.CachedPages), so I am assuming if I perhaps initialize the CachedPages map, clearing and rebuiling the cached pages could take place. Is that logic right? But then the timer, do I have to start that also, I presume so.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Scavenger has nothing to do with the browser. You should use ?versionnumber after your image name to force a reload of the pictures.
I hear you and thanks, this is my scenario.

I have about 12 ABMImage components in my page... So when I read each record from my db, I also get the image link which will be '../images/green.png' for example.

So I get the component with...

B4X:
Dim AprImg As ABMImage = page.Component("AprImg")

Then update its contents link with

B4X:
AprImg.Source = '../images/red.png'
    AprImg.Refresh

So instead of using '../images/red.png' in my .source property in this case I should use '../images/red.png?versionnumber'

Is the versionnumber the same as what will be the ABMShared.AppVersion variable?
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Sadly even with this statement...

B4X:
VarImg.Source = VarImgContents & "?" & ABMShared.AppVersion
    VarImg.Refresh

where VarImgContents points to something like '../images/red.png'

Replacing the png in the ../images folder whilst the WebApp is running does not reflect the new image, only after I have done a 'Clear Browse Data' that it reflects the new image, even if I close and reopen the page... :(
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Sadly even with this statement...
Obviously. You're just caching the same thing.

As you say it yourself, usage of this AppVersion is not correct as you change the image within the same version of the running app.

You will need to keep track of the version for YOUR images. (or use a random number, datatime.now, etc)
 
Upvote 0
Top