B4J Question [ABMaterial] Change logo

b4auser1

Well-Known Member
Licensed User
Longtime User
I have replaced logo.png provided in template with my own.
Browser still shows old one - I think from it's cache.
I managed to show the new logo after renaming the file and using the new file.
How to force to show the new logo file without renaming ?
 

Harris

Expert
Licensed User
Longtime User
Delete cache from browser.
I often get lazy and just rename the image (as you did), avoiding deleting cache - cause it will also delete things I want as well.
But, now you have to upload this new renamed image to your server... Which is more of a pain?
Too bad there isn't a one time - force cache refresh in browsers... (F5 doesn't cut it).
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
That will need some more splainin Lucy...
I was typing an answer on the phone during the commute and typing this short sentence was already a hassle due to the drivers superb driving style

It is the same trick as we use in the NavigateToPage() method for example (you can actually also use AppVersion in this case). So every time you restart your app, a new 'version' number will be added to the filename so the browser will reload the file as the 'url' has changed. The advantage of using the AppVersion is that it will only be reloaded when you restart your app, and inbetween it is cached.

So in this case if we do this:
B4X:
ABMShared.BuildNavigationBar(page, "Title","../images/logo.png?" & ABMShared.AppVersion, "", "", "")

with each restart, another number will be added after the '?' and the browser will reload it.

In the demo, I use this trick too in some places.

If you do want to reload it at runtime (e.g. for a real time photo webapp), you could use DateTime.Now:
B4X:
Dim img2 As ABMImage
img2.Initialize(page, "img2", "../images/sample-1.jpg?" & datetime.Now, 1)

Note: in the browser, try using Ctrl+F5 when you refresh instead of just F5.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
The url is the same name as previous. .??
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
alwaysbusyWell-Known MemberLicensed User

I was typing an answer on the phone during the comute..

Distracted driving laws in my country frown on this with heavy fines... However I feel your need to respond.
We can wait...
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
The url is the same name as previous
Indeed. The ?number makes it different for the browser. You can use this trick for other stuff too, like when loading a pdf or whatever file you are using.
In previous versions for ABMaterial I did this too for the .js and .css files to make sure the latest versions of the lib where loaded. In recent versions I've included the version number in the filename e.g. core.3.50.min.js as it was more efficient (it only had to reload it if I updated the ABMaterial lib).
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Did not know this. I thought the datetime we used as the currenrt ver was the latest.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…