Caching Gaussian Splats or other large files locally

What is the easiest way to get a web browser, or Babylon itself, to locally cache a gaussian splat (or other very large file) once downloaded and use the cached copy if present?

I have a few splats I am using in WebAR that are > 50mb, some even > 100mb in size. Chrome does not seem to cache them the same way it does images and such and so every time I load the webapp they redownload. My web host is going to kill me without a solution.

cc @Cedric

Just to make sure: you have closed DevTools or if opened, you unchecked “Disable cache”?

You could make use of the browser cache api: Cache - Web APIs | MDN (mozilla.org)

Then you could explicitly tell the browser to cache any file.

1 Like

I did a quick search and got same doc page as @Maxiviper117
I’m not aware of anything else. I’m curious to see if it works for you @Calsa as it might be usefull for other developers.

For my case it sadly won’t as I am using AR with my splats and BabylonAR only works on Chrome, so Modzilla tools won’t cut it.

Is there a way to allow a web app to read local files automatically, even a hack? I would imagine browser security would prevent this, but if I could download the file to the device (which typically stores it in something like a downloads folder longer term), then access that download from babylon to load the splats automatically, that may be a workaround for now. Then I would just need to prompt a user once to trigger the DL and once to confirm they want to load that file locally from then on out. What I am trying to avoid doing is having to go native app on this.

if I’m not wrong, it’s possible to open local files with the appropriate url. any restriction in that case @RaananW ?

So many different ways of doing that. Service workers might come in handy (as @Maxiviper117 already mentioned, with a perfect link to the Cache interface :slight_smile: ). I believe you misunderstood the link - MDN does not mean mozilla tools, these are usually web standards. Compatibility for cache: Cache - Web APIs | MDN

Another option is indexedDB and local manipulation on your end. What you can do is catch any request babylon is making (we have different interfaces for that), and if the URL matches some local cache you have defined, load the data from indexedDB, store as blob, get a URL for the blob, and return this URL instead. This should work as well, similar to the cache mechanism.

1 Like