Offline caching and usage

1. A concise explanation of the problem you’re experiencing.

I’m using CesiumJS inside a Xamarin.Forms app that uses a WebView (Android WebView based on Chrome) to display and interact with the 3D map. The app is often started in an offline context, as it’s a hiking (actually hiking and paragliding) app. Often you’re out in the great outdoors and don’t have a mobile network. In this case, CesiumJS doesn’t start up at all, even when the WebView uses caching. I already read the offline guide ( I’m using terrain and OpenStreetMap imagery layers.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

My guess is that the access to the URL fails when offline, since the answer contains the header “cache-control: no-cache”. Is there a way to store the returned data somewhere, e.g. the local database or the (I think already deprecated) app settings?

4. The Cesium version you’re using, your operating system and browser.

I’m using the latest CesiumJS, version 1.66, on Android using the Chrome browser.



CesiumJS should be able to run in offline environments, as long as the data you’re accessing is still accessible.

When you say “CesiumJS doesn’t start up at all”, do you mean you get a crash, or just no globe? If you’re accessing Cesium World Terrain from ion, or imagery from other providers, you’d need to get those datasets available locally (which is available for Cesium ion with an on-premise license

Otherwise, a code sample like this should work completely fine in an offline environment:

Let me know if that doesn’t work.

This sounds like a cool app! Is there a version publicly available?

Hi Omar,
thanks for your explanation. I’m indeed starting up with the terrain provider using Ion. The page stays black and no globe is shown, no crash. I could start without a terrain provider and set it afterwards, I guess.

About the offline Sandcastle example: doesn’t work on both my Android phone and Windows PC. I opened the page once, loading the globe with NaturalEarth imagery, then go into flight mode (or remove the network cable) and open the page again. The Firefox developer tools show that most files come from the cache, but the file “bucket.html” was requested online and couldn’t be loaded. The Sandcastle UI shows, but the actual CesiumJS window shows the browsers error page.



Instead of running the Sandcastle directly (which does require loading online resources), have you tried just running that CesiumJS code in that example offline? As long as you’re loading the CesiumJS library locally as well, this should work completely offline.

Hi Omar,
I think I fixed it by checking the readyPromise. When initialization fails, I wait until the app gets network connection again and then I retry. The change: