TikTok for Developers

Developer Docs

Last updated November 27, 2026

Host and Cache Remote Assets

Host selected assets on your own HTTPS server or CDN to reduce the total package size, or to deliver content separately from your code package. Then configure caching, so returning players reuse downloaded assets instead of downloading them again.

For package structure, subpackages, and size limits, see Manage Packages and Assets.

Prerequisites

  • A mini game that builds and runs in Client preview. For setup, see the Mini Games Quickstart.
  • An HTTPS server or CDN that you manage
  • Access to Development configuration for your app on the Developer Portal

Plan which assets to host remotely

Use remote assets to reduce the total package size or to deliver selected content separately. For example, keep level logic in the package and host later-level images or audio remotely.

To reduce package size, remove the bundled copies from the build. If your game needs an offline fallback, the bundled copy counts toward the package size.

You host remote assets on your own HTTPS server or CDN.

Flow diagram showing remote asset publishing, domain registration, loading, and either entering the scene or retrying after failure

Warning: Executable game code must stay in the main package or a subpackage. Don't download and run JavaScript from a remote URL. Remote hosting is for eligible assets only.

Configure trusted domains

If your game requests https://cdn.example.com/game/v1/meadow.png, register https://cdn.example.com on the Developer Portal in Development configuration > Security. Save the change before you test.

  • Register each host your game requests, including any redirect destination. Use HTTPS. A registered domain can't contain a path or wildcard.
  • You can register up to 20 domains. The asset URL itself can contain a path, such as /game/v1/meadow.png.
  • Keep domain verification turned on when you test on a phone. Turning it off for debugging doesn't configure the released game.

For the current domain rules, see Set Up Development Configuration.

Integrate and test remote assets

  1. Choose and publish assets. Select assets your game can request when needed, publish them to your HTTPS server or CDN, and record their URLs or asset manifest. Keep executable code in the package.
  2. Register every host your asset requests use as a trusted domain, including the host after any redirect.
  3. Connect the loader. Configure your engine's supported remote asset path, or use the Network Request APIs in a JavaScript project. Make the scene wait for its actual assets, not only for the subpackage to load.
  4. Plan for failures and updates. Handle timeouts and unavailable files, and let the player retry. Version asset URLs or manifests, and keep the assets that released game versions use. Manage cached files your game creates according to your loader's storage behavior.
  5. Rebuild and check. Confirm that the assets are no longer bundled, that the total passes precheck, and that the URLs are reachable on your target devices and networks. Test the first load, a repeat load, a failure, and a retry.

Download an asset in JavaScript

The following example downloads one remote asset. After you set up the Mini Games SDK and register your host, replace the example URL and implement the two functions for your game. The first function reads or decodes the downloaded file. The second keeps the current screen usable and offers a retry.

TTMinis.game.downloadFile({
  url: "https://cdn.example.com/game/v1/meadow.png",
  success(result) {
    if (result.statusCode === 200 && result.tempFilePath) {
      loadAssetFromFile(result.tempFilePath);
    } else {
      showAssetRetry(result.statusCode);
    }
  },
  fail(error) {
    showAssetRetry(error);
  }
});

tempFilePath is temporary. A successful download doesn't mean the asset is decoded or that it persists across sessions. Use your loader's storage strategy, and wait for the asset itself to be ready. For details, see Network Request and File.

Cache remote assets

Cache reuse determines whether returning players load the same remote assets again or enter gameplay right away. Configure caching in your source project, and check repeat launches on a phone. Registering a host alone doesn't make the game reuse files locally.

Understand what each cache layer reuses

The platform, your engine's loader, and your game code manage different data. Restarting the TikTok app doesn't always clear package caches, downloaded assets, or local files.

Layer

What it covers

Who manages it

What you must do

Package and subpackages

The main package, regular subpackages, and independent subpackages built into the mini game

The TikTok app

Rebuild and upload only when packaged code or bundled assets change.

Remote asset cache

Remote bundles, images, audio, and data files downloaded over HTTPS

Your engine's loader or your own downloader

Configure cache rules, keep cached files within size and concurrency limits, and version URLs for files that don't change.

Local files and player saves

Files saved with the File APIs, and key-value data written with the Data Storage APIs

Your game code

Keep player progress separate from downloadable assets, version saved data, and handle migration and cleanup yourself.

Diagram showing cold launch downloads bundle v1, repeat launch reuses the local cache, and an update downloads only v2 while preserving saves

If an update still shows outdated code, assets, or state after you configure caching, check manifests that change, bundle hashes, and whether the uploaded code version matches. For details, see Troubleshooting.

Configure remote asset caching in Unity

For AssetBundles and Addressables, configure remote caching in TikTokGame > Build Minigame before you export:

  1. Add your remote hosts to Cache domain List. This setting is separate from the trusted domains in Development configuration > Security on the Developer Portal. Add your CDN host, such as https://cdn.example.com, in both places.
  2. Exclude manifests that change in Uncache Files. When you set Cache domain List, you must add catalog and hash files that change, such as .hash and .json files, to Uncache Files, so returning players don't keep old catalogs.
  3. Keep each cached remote file under 10 MB. Files over 10 MB aren't saved locally and download again on each visit. Split large AssetBundles by level or feature.
  4. Don't send dozens of small remote requests at once. Group assets by scene into bundles of moderate size. Many concurrent writes can leave files uncached or remove older bundles early.
  5. Handle missing cached files. Use the SDK's file system cache checks to confirm files are ready locally, offer a retry if loading fails, and don't clear all cached files during normal play.

Configure remote asset caching in Cocos Creator

  • Use Cocos Creator's remote Asset Bundle workflow with the MD5 cache turned on, so unchanged remote bundles stay cached across launches and outdated versions are removed automatically.
  • Don't mark the same Asset Bundle as both a mini game subpackage and a remote bundle. Keep them separate, and check the build output.

Configure remote asset caching in a JavaScript loader

TTMinis.game.downloadFile() returns a temporary tempFilePath that might not persist across sessions. In your own downloader, save reusable files with FileSystemManager.saveFile(), track them in a versioned local index, and download a file again if the saved copy is missing or can't be read.

The following example saves a remote asset and reuses it in later sessions. Replace the URL, and implement readIndex(), writeIndex(), loadAsset(), and showAssetRetry() for your game.

// Illustrative example: persist and reuse a remote asset across sessions.
// Replace the URL and implement readIndex(), writeIndex(), loadAsset(), and showAssetRetry().
const fs = TTMinis.game.getFileSystemManager();

function loadCachedRemoteAsset(assetKey, url) {
  const index = readIndex(); // Maps assetKey -> { url, savedFilePath }
  const cached = index[assetKey];

  if (cached && cached.url === url) {
    fs.access({
      path: cached.savedFilePath,
      success() {
        loadAsset(cached.savedFilePath);
      },
      fail() {
        downloadAndSave(assetKey, url);
      }
    });
    return;
  }

  downloadAndSave(assetKey, url);
}

function downloadAndSave(assetKey, url) {
  TTMinis.game.downloadFile({
    url,
    success(res) {
      if (res.statusCode !== 200 || !res.tempFilePath) {
        showAssetRetry(res.statusCode);
        return;
      }
      fs.saveFile({
        tempFilePath: res.tempFilePath,
        success(saved) {
          const oldPath = readIndex()[assetKey]?.savedFilePath;
          writeIndex(assetKey, { url, savedFilePath: saved.savedFilePath });
          if (oldPath && oldPath !== saved.savedFilePath) {
            fs.removeSavedFile({ filePath: oldPath, fail() {} });
          }
          loadAsset(saved.savedFilePath);
        },
        fail() {
          // Saving failed (for example, quota pressure); still load the temporary file for this session.
          loadAsset(res.tempFilePath);
        }
      });
    },
    fail(error) {
      showAssetRetry(error);
    }
  });
}

For large downloads, the error code reference lists a 200 MB temporary directory limit for error 603301. Limit the total size of saved files, remove obsolete versions, and check that the File APIs are available in your target SDK version.

Version remote assets without breaking updates or saves

Combine local reuse with clear version identifiers, so updates download cleanly and never remove player progress.

  1. Version files that don't change by hash. Add content hashes to file names, such as Append Hash to Filename in Addressables or the MD5 cache in Cocos Creator, so only changed bundles download again.
  2. Keep the files that live builds use. When you publish new assets, keep the files that running or rollback versions reference available until those builds are retired.
  3. Keep cache cleanup separate from saves. Don't call clearStorage to clear asset caches. It removes key-value storage that might hold player progress. For details, see Data Storage.

Check first launches, repeat launches, and updates on a phone

Before release, check all three states on the same phone, account, and network. On Android with TikTok 48.1.0 or later, use Disable Client Cache, Clear Client Cache, and the startup details. For details, see Optimize Startup.

  1. Cold first launch: Start with a clean install or a cleared preview cache, open the game, and enter a scene that uses remote assets, such as Level 2. Check that the expected bundles download over HTTPS and render normally.
  2. Cold repeat launch: Close the game, restart the TikTok app, and reopen the same scene. In the network logs, check that downloaded bundles load from the local cache, while manifests that change are still downloaded.
  3. Asset update: Publish one updated remote bundle with a new hash and an updated manifest, then reopen the game. Check that only the changed bundle downloads and that player saves are intact.

Troubleshooting

Problem

Check next

Remote assets fail on a phone.

Check HTTPS, registered domains, redirects, the asset URL, and whether the file is reachable on the phone's network. Check the actual error and the retry path.

Repeat launches keep downloading the same remote assets.

Unity: Check that the CDN host is in Cache domain List, each cached bundle is under 10 MB, and startup or scene entry doesn't send dozens of small downloads at once. JavaScript: Check that you save tempFilePath with FileSystemManager.saveFile() instead of relying on temporary files across sessions.

Returning players keep old remote assets after an update.

Unity: Check that manifests that change (.hash and .json) are listed in Uncache Files, updated bundles use content-hashed URLs (Append Hash to Filename), and the uploaded code version matches the newly deployed catalog. JavaScript: Update the versioned key or URL in your local asset index, and remove saved files that were replaced.

The game works in Client preview but fails after upload.

Confirm that the uploaded build and configuration match the build you tested. Test the uploaded version in Preview, and check its logs, domains, and asset versions.

Next steps

TikTok for Developers