android - How to use disk cache to cache ParseFile -


i'm using parse , picasso load images onto parseimageviews. there i'm missing cache parse files? listview seems fetching file server every time , using disk cache comes picasso.

i don't see cache-control: max-age parameter in http responses of downloads of parse files(from amazon s3 parse stores them)

i have following code,

    final parseimageview pic = viewholder.img;     pic.setscaletype(imageview.scaletype.center_inside);     parsefile f = parseobject.getparsefile("image");     picasso.with(mcontext).load(f.geturl()).into(pic); 

any appreciated. thanks.

use okhttp client http transport picasso , specify disk , memory cache size:

okhttpclient okhttp = new okhttpclient();  cache cache = new cache(ctx.getcachedir(), cachesize);  okhttp.setcache(cache);  // use okhttp downloader downloader downloader = new okhttpdownloader(okhttp);  mpicasso = new picasso.builder(getapplicationcontext())   .downloader(downloader)).memorycache(new lrucache(size)).build(); 

setup request interceptor (example) okhttp client:

// add cache-control origin response (force cache)  client.networkinterceptors().add(new interceptor() {      private com.squareup.okhttp.request request;     private response response;     private string requesturl;      @override     public response intercept(chain c) throws ioexception {         request = c.request();          response = c.proceed(request);          if (!request.cachecontrol().nostore()                && !response.cachecontrol().nostore()) {          requesturl = request.urlstring();          // not cache keys or playlists             response = response             .newbuilder()             .header("cache-control","public, max-age=42000").build();          }           return response;      }    }); 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -