We have a backend where users can upload models themselves and the backend has two pages where they can view these models.
On the frontend there are 3 pages where models can be viewed, one of them has two canvases and another loads models in a sequence endlessly.
The thing is now if a user replaces a model (because it was faulty or too heavy or something) it will still display the old model in the preview.
I am not sure if disabling caching everywhere is a good idea? The models are not very big generally, but I do have one particular model that takes a couple seconds to load for example. So for loading a lot of models I would like to enable caching, but then users on the frontend won’t be able to see updates unless they hard refresh? Anyone have suggestions for this?
So from what I understand I am dealing with the engine cache here?
I could just disable the cache everywhere, but could also add some version checking or something via the database by just using a number and set it higher when a model is updated but how would I check if the model is cached and is updated?
1 - User uploads model
2 - Views model in viewer, but sees a mistake
3 - Uploads another model
4 - Views it in viewer again, but now sees the previous model
5 - Only when doing a hard refresh the new model is visible
So maybe I am wrong and this is the browser caching? I thought babylon also had an in engine cache going on.
EDIT - tried adding a v?=x suffix but this obviously won’t work for the skybox path loader function, so as there is only very little time left I am just going to add no cache meta tags to the frontend pages where content can be updated by the admin. Our models/skyboxes are quite small anyway so I don’t think it will be too much of an issue for now.
Mh alright that might have been useful, but it works for now.
One thing however I am looking into right now is that I am replacing a gltf model with another one, I am 100% certain the previous one is removed and the new model is being uploaded to the right folder because also tried it with completely different helicopter and that did work.
However when I open the gltf in blender it looks like this:
As you can see the propellers are supposed to be straight (angled won’t work properly right now). I checked and double checked but this file with angled rotors does not exist anymore… so this is not being cached or what? I am confused.
I even have these in the page:
It looks fine but the nose is pointing upwards when I drag it in, which was not the case with the other helicopters but I never have any issues with them pointing into the wrong direction they all face straight ahead.
But at this point I am really not sure what could somehow be caching this file?
Because at least here the rotor is straight, and mine just shows a file that doesn’t exist…
Mh not sure how you would want me to reproduce this if I don’t even know what is going on?
The no cache meta tags don’t seems to do much about this caching being disabled then, is there no way to just turn this all off to see if it works without it at least?
Alright do you have any suggestions where I could upload this file because this server is not supposed to have cors and I don’t have anything like dropbox premium to have a link or anything.
Ok good so you need to bypass cache from the model xhr. maybe you could do like david proposed:
BABYLON.WebRequest.CustomRequestModifiers.push((request, url) => {
// nothing to do for external requests
if (url.startsWith('https://') || url.startsWith('http://')) {
return;
}
// set our header for all internal requests
request.setRequestHeader('Cache-Control', 'no-cache');
});