Answer first
No. The Titanium restore API does not automatically clear cache, and there is no built-in restore-complete hook or permission to do so automatically.
Confirmed fact: Titanium core does not define a built-in restore-complete hook or automatic cache invalidation for backup restore. Ti.Filesystem exposes Ti.Filesystem.applicationCacheDirectory and Ti.Filesystem.applicationDataDirectory, but no API automatically clears cache after a restore operation.
Likely explanation: Cache remains intact after a restore because iOS and Android backup mechanisms restore app data while treating cache as a separate location. Titanium does not intercept the OS restore process, so stale cached files can persist and cause stale application state.
Recommended developer pattern
Detect a restore on first launch and clear cache programmatically. This is version-sensitive and must be tested on target SDK and OS versions.
- Persist a restore marker in user preferences on normal shutdown or on each successful launch. Use app version and last-run timestamp or a file hash stored in
Ti.App.Properties.
- On app launch, compare the marker against current filesystem state. A missing or mismatched marker relative to data files indicates a possible restore or reinstall.
- If restore is inferred, clear cache before the app accesses cached resources:
- Delete contents of
Ti.Filesystem.applicationCacheDirectory.
- Delete any app-managed cache subfolders under
Ti.Filesystem.applicationDataDirectory that you control.
- Update the marker to the current app version/timestamp and reload app state from source of truth.
Platform-specific limitations
iOS
iOS does not deliver a reliable restore completion callback to the app. Detection must be done on first launch after install or update. iOS backup inclusion rules generally exclude Caches from iCloud backup, but a local restore can still bring back data files while leaving cache files from the device.
Android
Android Auto Backup can restore data without the app running. The OS may evict cache under storage pressure, so manual clearing must be guarded and performed on launch. Do not assume cache is included in the backup.
Safety notes
- Do not clear cache on every launch. It degrades performance and network usage.
- Manual deletion while files are in use can cause runtime errors. Perform clearing before the app accesses cached resources.
- Behavior is version-sensitive across Titanium SDK releases and OS versions. Test on target platforms.
One diagnostic detail that changes the recommendation: Are you storing cache only in Ti.Filesystem.applicationCacheDirectory or also in custom folders under applicationDataDirectory? The paths to clear depend on this.