Keeping the loaded models in the cache of browser

when people reload my app and reload again a babylon.js model, any tips for keeping those models in the cache of browsers so that it takes them from cache instead of reloading them again?

Its clear how to do this while they are within the app, keeping them in memory etc, the issue is when they close and reopen the browser and launch the app again, any tricks to keep the models in the browser cache to reload them from there again? this already happens by default with the images ofthe app etc, just wondering how to push the models to behave like that as well :slight_smile:

thank you

Hi @javismiles

Caching seems working fine for me. What is your server setup for serving your static assets? Could you share your Network tab of your chrome dev tool?

@slin thank you very much Slin, look I attach a capture of what happens when I reload the app to reload one of the models I loaded earlier, actually I can see “disk cache” written in one of the cells, so maybe it is indeed reading it from cache? but the status is 200, shouldnt it be a different status number if it was really reading it from cache? or maybe it is indeed reading it from cache, what do u think?

actually I think that yes it may already be working, because if i load one of them for the first time then in the size column you see the size loaded, but if you then reload and load it again then it just says “disk cache” so i guess that means that indeed it must be loading it from the cache the second time, well that would be good news then

Hi @javismiles

Yes. It looks like the assets are actually cached. You can check the Disable Cache in Chrome dev tool to see the difference when it is not cached (file size column should show the download size instead of memory cache/disk cache).

but the status is 200, shouldnt it be a different status number if it was really reading it from cache

Status 200 is fine it indicates the cached content is fulfilled in the browser cache. A different status code? Do you mean 304 Not Modified? It involves requests to the backed and backend confirms that the local cached file is not changed.

1 Like

@slin great points, so it looks like its caching things which is great, thank you slin for the help :slight_smile: