Caching in WebGL

Since I have seen various reports of caching issues and haven’t gotten a concise answer to how caching currently works in WebGL, I wanted to open it up for discussion (and answers from the Unity team, if possible).

Based on my experience thus far, here is how I believe caching works/doesnt work in WebGL:

  • Uses the local browser cache store (indexedDB, etc) to cache assetbundles.

  • Question: Is this only the case when using WWW.LoadFromCacheOrDownload or does the “new WWW” constructor also utilize this cache?

  • IndexedDB doesn’t work in Firefox in iframes (i.e, Facebook Canvas apps) Details on this thread.

  • Question: Does this basically mean there is no caching for Unity WebGL Facebook apps in Firefox currently?

  • In Firefox, “clearing browser cache” does not actually clear the indexedDB database like it does in other browsers. The user’s profile folder/indexedDB must be deleted.

  • I read something somewhere that suggested loading assetbundles sequentially in a WebGL app rather than through coroutines because of the way disk i/o was handled (or something to that effect). Any truth to that?

Please share your caching experiences and if anyone has the answers to these questions, Id love to hear them.

Thanks much!

Crickets…

Am I that far off-base with how caching is currently working in WebGL?

Only using WWW.LoadFromCacheOrDownload.

Currently, correct - though I’ve seen facebook engineers come up with a workaround to that by implementing their own AssetBundle caching mechanism using the localStorage API to store data themselves, and then using AssetBundle.CreateFromMemory to load the data. However, Mozilla engineers told me that they plan to lift the restriction on using IndexedDB in iFrames, so this problem will likely go away in the future.

This is not something I’m aware of.

Jonas,

Thanks very much for confirming/answering my questions!