i'm trying display listview lot of (remote) images. i'm trying use volley task.
volley works, not enough. in imageloader.get volley has following piece of code:
final string cachekey = getcachekey(requesturl, maxwidth, maxheight); // try request in cache of remote images. bitmap cachedbitmap = mcache.getbitmap(cachekey); if (cachedbitmap != null) { // return cached bitmap. imagecontainer container = new imagecontainer(cachedbitmap, requesturl, null, null); imagelistener.onresponse(container, true); return container; }
however, getcachekey produces key this:
/** * creates cache key use l1 cache. * @param url url of request. * @param maxwidth max-width of output. * @param maxheight max-height of output. */ private static string getcachekey(string url, int maxwidth, int maxheight) { return new stringbuilder(url.length() + 12).append("#w").append(maxwidth) .append("#h").append(maxheight).append(url).tostring(); }
i.e. appends "metadata" width , height key.
this key never produces hit , if image not in l1 cache fetched online. when image fetched online saved in disk-cache volley saves url (and url) key.
is expected behaviour? missing something?
the reason you're not getting hits because default behavior in volley disk caching dependent on http headers of element you're requesting (in case, image).
the way volley works is:
imageloader
checks l1 cache image (memory cache providedimageloader
in constructor). if available return image.- request processed
requestqueue
. checks l2 (disk cache) image. - if found in disk cache, check image expiry time. if not expired, return.
- download image , return it.
- save image in caches.
if want default settings work, images must have cache-control
header max-age=???
question marks indicate enough seconds time downloaded.
if want change default behavior, i'm not sure, think have edit code bit.
look @ cachedispatcher
class in volley source.
Comments
Post a Comment