Possible to cache the glb/mp4 files that a build spits out?

Is there a way to cache the glb/mp4 files in a build? Asking for a localised use of a site on a fullscreen PC at an event where I want the loading to be fast.

Original Post on Discord

by user 103054507105067008

Isnt that what the browser is doing already?

Probably, just passing on the question as a client’s dev asked

by user 103054507105067008

When on loading the same page it seems to need to reload the glb again, even on local server files

by user 103054507105067008

What does localised version mean? Do you have different glbs too or just mp4s per language?

Just the one glb for the scene, the mp4 is just a video used in the scene

by user 103054507105067008

Might be firefox specific btw

by user 103054507105067008

What might take a moment is building the scene with the components (depending on scene complexity). If you have the same url / glb / files that you load and caching is enabled in the browser the download is what is taking less time.

Maybe the binary blob could be cached in local storage of the browser to speed the process a bit but im not sure about that.

I’ll continue to explore options, that is an idea

by user 103054507105067008

How long does it take to refresh the page on first time load with cleared caches and subsequent refreshes with the cached files?

First load is long, subsequent refreshes are fast, this is on Chrome, I know this other dev is on Firefox so seeing if Firefox is the issue

by user 103054507105067008

For sure the caching works. Might be more that I need to reliably hide the load is all

by user 103054507105067008

Yeah i wouldnt expect huge speedups if any tho (just assuming the scene has not trivial complexity and the bottleneck is creating textures/meshes/components in threejs)

Maybe he has caching disabled then?

Yes, a custom event should get you there for now (you could even emit one static event from a component.start method that the client/frontend dev can subscribe to)

Start is called as in unity the first time the renderloop is running when a component becomes active

I’m checking, I’ll go back to exploring options for an event that reliably fires when content has loaded so I can at least cover the load with another screen in html

by user 103054507105067008

Okay thanks!

by user 103054507105067008

One thing I saw more often than not is that a dev always has the Chrome Debugger or Firefox Debugger open, which by default disables caching (by design). So worthy to check if that’s the case

If you want proper persistence of data for a local installation you can turn it into a PWA which then caches all data you want to cache on installation.