I am new to work on Volley and on caching too :P. Though I have already gone through a number of articles & posts related to Image Caching with Volley but I am still not clear with the best/preferred way for Image Caching with Volley. Like disk caching or memory? What support does Volley already provide and how (related to L1 and L2 caching support)? I am using NetworkImageView in my case, to populate a list view with images to be fetched from net. Thanks in advance!
For image caching, volley expects you to provide an implementation memory cache for images. This cache is used during the up time of the app for quicker loading times using the memory.
Not related specifically to images, Volley has its own disk cache which it uses to cache EVERY response it gets, with the default strategy of caching according to cache headers of the HTTP response.
If the images you are loading in your app have cache headers, they will be cached according to them on the disk, otherwise the will not be.
If you're unhappy with this strategy and want to force disk caching, you'll have to edit / add a little code that changes the caching strategy. There are many ways to achieve this, one being providing your own implementation to parsing the HTTP headers. Take a look at HttpHeaderParser
in the Volley source.
ImageLoader
constructor. If you want to force caching you have to do exactly that - edit the Volley source code to either parse every HTTP header like it had a cache-header or change the check for entries in the cache. Also, if my answer helped, I'd appreciate it if you accept it, thanks. –
Laconic © 2022 - 2024 — McMap. All rights reserved.