0

After reading several documentations, i want to clear some points

Reference: this

  1. For Picasso to cache my image into memory, do i have to enable "Cache-control" header in my response?

  2. If i am using OkHttpDownloader with Picasso,will it still require me to enable the header?

    public Picasso getImageLoader(Context ctx) {
    
    Picasso.Builder builder = new Picasso.Builder(ctx);
    
    builder.downloader(new OkHttpDownloader(ctx) {
        @Override
        protected HttpURLConnection openConnection(Uri uri) throws IOException {
            HttpURLConnection connection = super.openConnection(uri);
    
            connection.setRequestProperty("X-User",user.getUsername());
            connection.setRequestProperty("X-Token",user.getToken());
    
            return connection;
        }
    });
    return builder.build();
    }
    

3 Does disk caching work in Picasso on Android 4.3 or lower. Will it load my image from disk if the net is disconnected?

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
Diffy
  • 2,339
  • 3
  • 25
  • 47
  • 1
    See: [question]:http://stackoverflow.com/questions/18944773/how-to-implement-my-own-disk-cache-with-picasso-library-android Jake Wharton's answer is correct – happyhls Dec 05 '14 at 12:19
  • Check my previous answer here, hope it help you: [http://stackoverflow.com/a/29812708/672773][1] [1]: http://stackoverflow.com/a/29812708/672773 – João M Apr 23 '15 at 02:55

1 Answers1

1

In Picasso Caching is enabled by default.

and other settings you can do by this function memoryPolicy(,)

Picasso  
    .with(context)
    .load(UsageExampleListViewAdapter.eatFoodyImages[1])
    .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)
.into(imageViewFromDisk);
jknair0
  • 1,194
  • 13
  • 24