Skip to Content
Platform.Ontology

Cache and temporary storage eviction

The system may delete cache and temporary files when storage runs low; other files stay.

Works without askingFiles and storageStorage limitsAndroid and iPhoneIn the background

In one line

Can store temporary files that the system may delete when your storage runs low

The system may delete cache and temporary files when storage runs low; other files stay.

Apps cannot rely on cache data staying. Android clears cache dirs and reports a cache quota; iOS purges Caches and tmp when space is needed, and flags files as purgeable.

What it can and can't do

What the user does: Nothing. The app saves cache files while you use it

It can

  • Save cache and temporary files, such as image thumbnails
  • Keep them until storage runs low or you clear them
  • Rebuild them after the system deletes them

It cannot

  • Keep cache forever; Android clears oldest cache first when space is low
  • Count on cache staying while iPhone is low on storage; it is purged when the app is not running
  • Lose Documents or Application Support files on iPhone from this purge
  • Stop you from using Settings, then Storage, then Clear cache on Android

How it differs between platforms: Android sets a cache quota and clears oldest first. iPhone purges the caches folder while the app is not running.

On Android and iPhone

AndroidiPhone
StatusSupportedSupported
First versionAndroid 8.0 (API 26)iOS 5.0
Permission or entitlementNoneNone
Protection levelnonenone
How access is grantednonenone
What the user seesSettings > Storage > Clear cacheNone
How long it lastsCache cleared on low storage or by the user; per app cache quota via StorageManagerCaches and tmp purged by the system when low; Documents is not
How to take it backSettingsNot user controlled
Store policyNone listedNone listed
APIContext.getCacheDir(), StorageManager.getCacheQuotaBytes()FileManager caches directory, volumeAvailableCapacityForImportantUsage
NotesLow storage clears oldest cache first; quota set by the systemPurge happens while the app is not running; Documents and Application Support are kept

Data you get

What comes back: Free storage
Shape: integer
How often: Live

FieldTypeUnitRangePrecision
available_bytesintegerbinary0 to device size1 byte

Technical limits

  • Cache is not durable
  • Free space readings fingerprint lightly

The story

What it is

The phone may delete an app's cache and temporary files when it runs low on space.

For you

When your storage is nearly full, the phone may quietly wipe cached images and temporary files. You may see an app reload things it had already downloaded. Your saved files stay.

For makers

Makers must treat caches as disposable and rebuild them when they vanish. It lets the phone free space without asking you, and makers should not hide needed files in caches.

Where you see it

TypeExampleApps
mediaA streaming app loses its cached thumbnails when space is low and downloads them again.None named
socialA photo feed app reloads old images after the phone cleared its cache.None named
mapsA map app re downloads map tiles it used to have stored in cache.None named
gamesA game re downloads optional textures but keeps your saved game files safe.None named
musicA music app keeps your downloads in permanent storage so they are not wiped, but cached previews may go.None named
developerA developer tests low storage to see if the app copes with missing cache.None named

Risks

  • Lost cache slows apps
  • Wrongly stored data can vanish

Android and iPhone in short

  • Android: Android clears cache folders and reports a cache quota for each app.
  • iPhone: iOS purges Caches and tmp folders when space is needed and flags files as purgeable.

Good uses and abuse

Legitimate uses

  • Offline content that can be rebuilt

Known abuse

  • Storage size fingerprint

Scores

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility2 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits4Rough identifying entropy, when known

History

  • 2013-09, iPhone iOS 7: System purges Caches when space is needed
  • 2017-08, Android 8.0 (API 26): Cache quota APIs introduced

Same idea on the web

Sources

How well checked: Based on official documentation.

On this page