Local-only display sources
src, resolve, and bind return a source only after a local file exists. Your img or video tag receives a local webview URL.
Local-only display sources
src, resolve, and bind return a source only after a local file exists. Your img or video tag receives a local webview URL.
Persistent native storage
Cached assets live in app-owned persistent storage, not the platform cache folder that the system may evict under pressure.
Protected CDN support
Pass headers to the native fetch for signed or authenticated assets while the web element still loads only the local file.
Framework-friendly binding
Bind native cache resolution to plain HTML, React refs, Vue refs, or any framework that can assign an img or video src.
@capgo/capacitor-asset-cache caches large images, videos, and other CDN assets in app-owned persistent storage, then gives the web app a local source URL for display.
The normal path is:
AssetCache.bind(element, path) or AssetCache.src(path).Use Asset Cache when your app displays heavy remote media that should survive normal storage pressure:
<img> and <video> should not fetch protected URLs directlyconfigure(options) sets default CDN and revalidation behavior.bind(element, path, options?) updates an image or video element when the local file is ready.src(path, options?) returns a local source string for framework state.resolve(path, options?) returns the local source plus cache metadata.get(options) resolves a remote URL into persistent native file metadata.remove(options) removes one cached asset by key or URL.clear() removes every cached asset managed by the plugin.list() returns cached assets that still exist on disk.getCacheSize() returns total cached bytes.getPluginVersion() returns the native implementation version marker.The cache can be checked in different ways per asset or through defaults:
| Strategy | Behavior |
|---|---|
never | Use the local file when present. |
ttl | Re-download after maxAgeSeconds. |
always | Revalidate on every call and send known validators. |
etag | Use the known HTTP ETag validator when present. |
last-modified | Use the known HTTP Last-Modified validator when present. |
On iOS, files are stored under Application Support and the cache root is excluded from iCloud backup. On Android, files are stored under the app internal files directory.
The cache is hidden inside the app sandbox and is not visible as public user media. It is removed when the app is uninstalled, when the user clears app data, or when your app calls clear() or remove().
If you are using @capgo/capacitor-asset-cache to plan persistent media loading, connect it with Getting Started for implementation details, @capgo/capacitor-downloader for explicit background downloads, @capgo/capacitor-file for general local file access, and Using @capgo/capacitor-asset-cache for the tutorial.