Did you know that since Titanium 3.1 remote images are cached automatically on Android, just like they have always been on iOS?
Well, I don’t blame you for not knowing, since the Appcelerator Docs on this very day still preach the best practice of manually caching remote images. I didn’t know either when I made the fairly popular CachedImageView widget to bring this technique to Alloy.
When I found out in August I created a ticket requesting the docs to be updated right away. Yesterday, this ticket has been resolved so we can expect the docs to be updated some time soon.
Comments
J23
Wow this is great. I actually didn’t know this. Should simplify things for me greatly. Thanks for sharing.
developer82
Great! so that means that any ImageView that loads an image from a URL caches it for further use?
What about if you wish to clear the cache?
Fokke Zandbergen Post author
@developer82 as it says in http://docs.appcelerator.com/titanium/latest/#!/guide/Image_Best_Practices-section-30082525_ImageBestPractices-Cachingremoteimages:
On the Android platform, the cache is limited to 25 MB and data remains for the lifetime of the application (as long as it’s installed on device). On the iOS platform, the cache size is not predetermined (size cannot be guaranteed) and data remains there until iOS cleans the directory (needs more local storage). To manually clean the cache directory, delete the files in the applicationCacheDirectory.
Bitter Truth
Your so called popular https://github.com/fokkezb/nl.fokkezb.cachedImageView has misspelled “nativePah” (instead on nativePath) at line 71 in widget.js file. Also it crashes on android phones, especially while calling widget multiple times.
Fokke Zandbergen (@FokkeZB)
@Bitter Though I encourage people to use the built-in caching, I have fixed the typo. Thanks!