Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volley : Image Caching

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!

like image 261
arorak Avatar asked Oct 16 '13 06:10

arorak


1 Answers

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.

like image 64
Itai Hanski Avatar answered Nov 12 '22 18:11

Itai Hanski