DylanD Posted October 2, 2018 Share Posted October 2, 2018 Hey everyone, I was curious if my understanding of how babylonjs and resources work with caching. The way i understand it works is that if I load a resource it becomes cached until that page is reloaded/cache is emptied. I think that it works this way for all of the resource types I am using (sound files, scene files/models, textures, and images). However I looked into it a bit and read this doc https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb Which makes me think that the resources are only cached if I declare it so in the manifest files. However this is an older version of babylonjs so maybe it is outdated? I also read this Which makes me a bit more confused, however it seems that the manifest is for .babylons only, or could i put that on all the files? So I was wondering is my understanding of how babylonjs caches, incorrect? How does babylonjs cache things (sound files, scene files/models, textures, and images)? If so do i just need to add a .manifest file to each resource I want cache? Any Ideas? Quote Link to comment Share on other sites More sharing options...
DylanD Posted October 2, 2018 Author Share Posted October 2, 2018 To add on. In my game i have tested, loading textures into a array, then also in the same scene, loading the texture again and when i load it the second time its almost instant, making me think it is already cached. Not sure where i read that it worked like that though. But it correlates with my testing. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 2, 2018 Share Posted October 2, 2018 Hello, so there are different levels of caching. The second one you mentioned is the engine cache. All texture contents are cached by the engine so if you load the same texture twice, it will be instant (and resource will be shared to save memory). There is also a cache per browser (the IndexedDB one). This one is controlled by the manifest file. If no manifest, there is no caching DylanD 1 Quote Link to comment Share on other sites More sharing options...
DylanD Posted October 4, 2018 Author Share Posted October 4, 2018 On 10/2/2018 at 11:58 AM, Deltakosh said: Hello, so there are different levels of caching. The second one you mentioned is the engine cache. All texture contents are cached by the engine so if you load the same texture twice, it will be instant (and resource will be shared to save memory). There is also a cache per browser (the IndexedDB one). This one is controlled by the manifest file. If no manifest, there is no caching Thanks!, thats pretty cool. So as long as i dont have multiple engines or switch engines I can use engine caching. So are only texture contents cached by the engine? if so is there a way i could force the engine to cache other resources like sounds and models, or would that be done by the browser caching? Also if i had to use browser caching i would just need to add "$name.manifest" to my resources folder and add this to each .manifest { "version" : 1, "enableSceneOffline" : true, "enableTexturesOffline" : true } Then whenever i try to load the resource it should load instantly or at least super fast. Sorry im very curious about this as i try to make my game a bit faster with loading, by caching. Thanks! Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted October 4, 2018 Share Posted October 4, 2018 @Deltakosh, sorry for the raw copy-paste ? @DylanD, do not be sorry to ask questions. On the contrary, if the doc' is not clear, you have to ask without hesitation (and the doc' have to be updated ) DylanD 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted October 4, 2018 Share Posted October 4, 2018 On the contrary! Thanks a lot for that Quote Link to comment Share on other sites More sharing options...
DylanD Posted October 5, 2018 Author Share Posted October 5, 2018 21 hours ago, V!nc3r said: @Deltakosh, sorry for the raw copy-paste ? @DylanD, do not be sorry to ask questions. On the contrary, if the doc' is not clear, you have to ask without hesitation (and the doc' have to be updated ) So it would seem i can only cache texture files with the engine. So for browser caching, as long as i make a .manifest file i can cache anything right? ie, Sound files Models Shaders(not sure if they are even worth caching since they are small but still curious) Can these^ also be cached with a simple manifest file? Thanks for the help you guys !! Quote Link to comment Share on other sites More sharing options...
DylanD Posted November 15, 2018 Author Share Posted November 15, 2018 Hey guys, looking into caching again, i was wondering https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb this doc says as of Babylonjs V4.0 we use BABYLON.IDBStorageEnabled = true; I was wondering if this is in 4.0.0-alpha.8 or if it was meant for when V4.0 is in a release build, as it does not seem to be in 4.0.0-alpha.8 If it is what am i doing wrong? I put that line of code at the very start of my code and it says it doesnt exist on type babylonjs. I have also tried other areas of my code and it doesnt work there either. How am i supposed to use BABYLON.IDBStorageEnabled = true; Quote Link to comment Share on other sites More sharing options...
DylanD Posted November 15, 2018 Author Share Posted November 15, 2018 I was also wondering that doc mentions that I need to add a .manifest to my scene ("To enable offline support, the first thing you need to do is create a .manifest file associated with your scene. It should be named NameOfYourScene.babylon.manifest." ), however my main scenes are not saved as .babylon's(or saved at all for that matter), they are initialized in code as they are basic/procedurally generated. How will this impact my ability to to cache other things such as sound files? From my understanding i should be able to cache them still. Quote Link to comment Share on other sites More sharing options...
Guest Posted November 15, 2018 Share Posted November 15, 2018 Doc is wrong (I'll fix it) Please use BABYLON.Database.IDBStorageEnabled = true; Regarding the caching of your files, this should not be a problem (you can also just use engine.disableManifestCheck = true to avoid the manifest check) DylanD 1 Quote Link to comment Share on other sites More sharing options...
DylanD Posted November 16, 2018 Author Share Posted November 16, 2018 19 hours ago, Deltakosh said: Doc is wrong (I'll fix it) Please use BABYLON.Database.IDBStorageEnabled = true; Regarding the caching of your files, this should not be a problem (you can also just use engine.disableManifestCheck = true to avoid the manifest check) Thanks! with the engine.disableManifestCheck = true i dont need to make manifest files for all my files? Or is that just for the scene one ? Quote Link to comment Share on other sites More sharing options...
Guest Posted November 16, 2018 Share Posted November 16, 2018 no need for all your files DylanD 1 Quote Link to comment Share on other sites More sharing options...
DylanD Posted November 16, 2018 Author Share Posted November 16, 2018 28 minutes ago, Deltakosh said: no need for all your files Great! This will save a lot of hassle. (and loading time hahahaha) Quote Link to comment Share on other sites More sharing options...
Nandha Posted February 23, 2019 Share Posted February 23, 2019 Even after writing manifests I am not able to cache the .mtl files of my models. My manifest file is: { "version" : 1, "enableSceneOffline" : true, "enableTexturesOffline" : true } the .obj files of my custom made models are cached, but not my .mtl files of the models. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.