# Performance and caching

> How much is downloaded, what is cached, and how one download serves many web sites.

## What a visitor downloads

| Part | When | Cached |
|---|---|---|
| Embed script (a few KB) | every page view, short cache time | yes, minutes |
| Player page and loader (small) | first view of a player version | yes |
| 3D engine (code and base data, about 115 MB compressed in the current version) | first visit | yes; files are named by their content, so a new player version only downloads the parts that changed |
| Character and stage | when they are first shown | yes, same rule |

Later visits on the same site start from the cache and transfer about 1 MB.

## Download once, use on many sites

Browsers keep the cache of a frame separately for every top-level site (cache partitioning). Without help, a visitor who saw the digital human on site A downloads everything again on site B.

The player asks the browser for access to its own, unpartitioned storage (Storage Access API, `requestStorageAccess({ indexedDB: true, caches: true })`). Where the browser grants it, every site that embeds the player shares **one** download.

| Browser | Shared across sites | Notes |
|---|---|---|
| Chrome, Edge (default settings) | **yes** | granted without a prompt while third-party cookies are allowed (the default) |
| Chrome, Edge in Incognito, or with third-party cookies blocked | after one opt-in | a small button "⚡ Auf allen Seiten schneller laden" appears below the digital human; after the visitor confirms (and allows Chrome's prompt), the next visits share the cache. Until then: per-site cache |
| Firefox | no | the browser does not share non-cookie storage across sites |
| Safari (macOS and every iPhone browser) | no | per-site cache |

Measured on 17 November 2026 (Chrome, same visitor, two different sites): site A 116.7 MB, then site B **1.0 MB** with the shared cache; without it, site B downloads 115.9 MB again.

Measured with the next player build: the second site requested none of the 14 add-on packages (stage settings, animations) either — they came from the shared cache.

The player reports what it got in its `started` message: `storage: 'shared'` (one cache for all sites), `partitioned` (per-site cache; `storageOptIn: true` when the opt-in button can help), `off` (disabled).

| Script tag option | Effect |
|---|---|
| (none) | share the download across sites where the browser allows it |
| `data-shared-cache="consent"` | share only after your consent tool called `Aimigo.setSharedCacheConsent(true)` on this site (applies from the next page view); until then per-site cache |
| `data-shared-cache="false"` | always per-site cache |
| `data-storage-opt-in="false"` | never show the opt-in button |

> [!NOTE]
> Sharing across sites is something browsers restrict on purpose (it could be used for tracking). The player uses only the official API and stores only program files: no personal data, no identifiers. Where the browser says no, it uses the normal per-site cache.

## Switching it off (one place for all sites)

Sharing is on by default. Every visitor can switch it off for all pages at once — and delete the stored files — at `https://player.aimigo.live/tools/shared-cache.html`. The player then loads once per page. Link this page in your privacy policy, for example:

> *Shared cache of the Aimigo digital human:* this page embeds the Aimigo digital human. So that you download it only once, your browser keeps its program files (no personal data) in a cache of the player domain and reuses them on every page that embeds it. You can switch this off for all pages at https://player.aimigo.live/tools/shared-cache.html.

If your site needs consent first (consent tool), use `data-shared-cache="consent"` from the table above.

> [!PLANNED]
> **Aimigo player domain with CDN.** The player moves to its own domain with a content delivery network: faster first downloads worldwide and one stable address for the shared cache. The script address in this documentation changes then.

## Tips for your page

- Put the script tag at the end of `<body>`: it never delays your own content.
- Pages where only some visitors use the digital human: use `data-auto="false"` and call `Aimigo.mount()` when the visitor clicks "Talk to us". Visitors who never click download nothing.
- Use one instance per page.
- Keep audio short and compressed (MP3); the page converts it before sending.
