Use Lru Image Caching In Conjuction With Httpresponsecache For Disk And Memory Caching
Initially the objective was to use both disk and memory cache. This would require implementing LRU cache and DiskLruCache. However, since HTTPResponse cache uses disk space, I chos
Solution 1:
If anyone wants to re-use any of the above code, I would take only the http response cache and not use the LRU cache since especially if you are caching webservice response e.g. JSON,xml. Why?
I once lost 200MB of device storage due to the LRU cache implementation above.
Advantages of HTTPResponseCache:
- Caches HTTP and HTTPS responses to the filesystem so they may be reused, saving time and bandwidth
- HttpUrlConnection does: Automatic handling of the caching mechanisms,
- Speeds up response time of the application with the help of HttpResponseCache
- It has been available since API level 1=> it has stood the test of time and is robust
On the other hand:
While LRUCache has its advantages over DiskLRUCache:
- You have to implement the class (and other helper classes), meaning if the code on android developers changes, you will have to constantly download and edit your local version after your app breaks after the previous implementation would have been deprecated.
- After removing the image, you might still find your disk space being used as the image will be somewhere in your device (as with my case).
That is the conclusion...
Post a Comment for "Use Lru Image Caching In Conjuction With Httpresponsecache For Disk And Memory Caching"