Caching Ads

Preload ads on your users’ devices to boost their experience! Ads will load faster when requested, and you can verify that an ad is available before displaying it.

Use the following methods to cache ads so they can be displayed later. We use CBLocationHomeScreen as our example.

  • Chartboost.cacheInterstitial(CBLocation.LOCATION_HOME_SCREEN);
  • Chartboost.cacheInterstitial(CBLocation.HomeScreen);

Checking for cached ads 🔗

Use these methods to check if an ad has been preloaded before you try to show it. If an ad isn’t already cached, you should probably cache one!

  • if (Chartboost.hasInterstitial(CBLocation.LOCATION_HOME_SCREEN)) {
    else {
  • if (Chartboost.hasInterstitial(CBLocation.HomeScreen)) {
    else {

Optional: You also can receive notification from the SDK when an ad is successfully cached by implementing these delegate methods.

  • public void didCacheInterstitial(String location)
    public void didCacheRewardedVideo(String location)
  • void didCacheInterstitial(CBLocation location)
    void didCacheRewardedVideo(CBLocation location)

If the cache calls fails, a didFailToLoadInterstitial delegate method will fire. This delegate also fires if you call showInterstitial and an ad fails to display. Do NOT make cache or show calls inside didFailToLoad delegates.

  • public void didFailToLoadInterstitial(String location, CBImpressionError error)
    public void didFailToLoadRewardedVideo(String location, CBImpressionError error)
  • void didFailToLoadInterstitial(CBLocation location, CBImpressionError error)
    void didFailToLoadRewardedVideo(CBLocation location, CBImpressionError error)

Autocaching 🔗

Chartboost SDKs automatically cache ads after they’ve been successfully displayed, however, it’s best practice to also manually cache ads at bootup or other relevant points in your app before you need to display them.

Autocaching will not cause unnecessary network requests. Any cache calls will only send network requests if the cache is empty at a specific location.

Use the following SDK methods to toggle autocaching.

  • Chartboost.setAutoCacheAds(boolean);
  • Chartboost.setAutoCacheAds(boolean);

Some more things to know about caching 🔗

  • [Chartboost showInterstitial:CBLocationHomeScreen]; displays a cached interstitial if one exists. Otherwise, it will request one from the server.
  • We recommend caching for optimal performance and user experience, however, it’s always a good idea to be conscious of your users’ data usage.
  • Cached interstitials automatically expire after 24 hours.
  • Cache requests are asynchronous. Keep this in mind if you cache many interstitials while loading other data for your app.

Last modified November 27, 2023