Make model textures expire from browser cache


I am using an editor to make changes directly on the asset folders inside a model (material, textures) etc. Using the PlayCanvas engine directly.

Everything is working smoothly as the json structure is quite readable and adaptable.

The only issue is the following:

When I directly modify a texture inside a subfolder, using a server php script, I can’t find a way to reload the material/asset of the model to display the new texture.

Even if I reload the page, as I final solution, the model displays the cached image file. I try putting a timestamp on the asset loadFromUrl function, but that only reloads the json from scratch.

Is there a way to explicitly tell PlayCanvas to reload an assets or all assets from scratch?

Or any other ideas on how to fight the browser cache.

Thank you in advance,

If this is only for local testing you could open your browser console and choose to Disable Cache when the console is open. This won’t work in production obviously but it might be enough for your purposes?

Another way like you said is to add some sort of timestamp to the asset URL. We usually add the file hash as a timestamp - each time an asset file changes we recalculate its MD5 hash and update the asset with the new info. If you don’t have any of that on your end, you could add a timestamp to the URL of each texture. To do that you probably have to change the material JSON file which contains URLs to each texture.

Yet another way is to fix this on your web server. There are usually ways to set it up so that it knows to serve the new file when it changes instead of using the cached version. Depends on what web server you’re using.