| aa910fab | 13-Jan-2021 |
Eric Samelson <[email protected]> |
[android] migrate OkHttp cache to application cache directory (#11600)
# Why
Follow-up to #11599. Since OTA update assets are stored in a separate location, it's better to keep the OkHttp cache i
[android] migrate OkHttp cache to application cache directory (#11600)
# Why
Follow-up to #11599. Since OTA update assets are stored in a separate location, it's better to keep the OkHttp cache in the application cache directory, rather than the files directory -- this allows the OS to clean up files if it needs to, and reduces the chance that developers' application code will unexpectedly interfere with the OkHttp cache.
# How
- Moved OkHttp cache to `Context.getCacheDir`, and renamed it to match the name of bare RN OkHttp caches.
- Added some deletion logic for the old cache in `Context.getFilesDir`. After deleting we set a key in SharedPreferences so we don't try to delete again.
- Also increased the maximum cache size to 50Mb -- this is [recommended in the OkHttp docs](https://square.github.io/okhttp/caching/). I checked [`StorageManager.getCacheQuotaBytes`](https://developer.android.com/reference/android/os/storage/StorageManager#getCacheQuotaBytes(java.util.UUID)) for the cache directory of a fresh installation of the Expo Go client on my Pixel 2, and got 64Mb. Since the cache directory also includes a few other caches (image, picasso, home experience data) 50Mb seems like a reasonable maximum size for the OkHttp cache.
- Finally, removed some extraneous logic around the OkHttpClient builder that was specifically for ExpoKit apps.
# Test Plan
Ran the same tests from #11599 again.
show more ...
|