0

Im using Picasso and okhttp to download and cache images onto the disk. Im using the below code snippet to set a cache of 10MB to the okhttp client and using it for Picasso.

File folder = new File(context.getCacheDir(),"HomePageCache");
if (!folder.exists())
   folder.mkdir();
okHttpClient.setCache(new com.squareup.okhttp.Cache(folder, 1024 * 1024 * 10));
OkHttpDownloader okHttpDownloader = new OkHttpDownloader(okHttpClient);
picasso = new com.squareup.picasso.Picasso.Builder(context).indicatorsEnabled(true).downloader(okHttpDownloader).build();

This is working perfectly most of the time caching and reloading images even when offline , but the problem is that sometimes it just clears the image cache completely.

I am checking the size of the image cache just to be sure, and it has never crossed 2 MB.

Is there any other reason why my cache is getting cleared?

Venkata Narayana
  • 1,657
  • 12
  • 25

1 Answers1

0

Like Nikola pointed out in the comment, the cache expire header was responsible for invalidating cached images.

Venkata Narayana
  • 1,657
  • 12
  • 25