53

I am using Glide 4.1.1 in one of my android application. I am using it with below code and not facing any issue in application.

Glide.with(context)
                .load(constant.BASE_URL+"images/"+data.getPicture())
                .apply(new RequestOptions()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .dontAnimate()
                .centerCrop()
                .dontTransform())
                .into(holder.imageView);

I have doubt in .diskCacheStrategy(DiskCacheStrategy.ALL) Option. There total five type option located with this like below

.diskCacheStrategy(DiskCacheStrategy.ALL)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.diskCacheStrategy(DiskCacheStrategy.DATA)
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)

I have tried to find its documentation but not able to find difference between this. Let me know if someone have used it and have idea what is difference between this all and when should we use it. Thanks

Priya
  • 1,602
  • 4
  • 22
  • 37

1 Answers1

117
  • Glide 3.x & 4.x: DiskCacheStrategy.NONE caches nothing
  • Glide 4.x: DiskCacheStrategy.DATA, Glide 3.x: DiskCacheStrategy.SOURCE caches only the original full-resolution image.
  • Glide 4.x: DiskCacheStrategy.RESOURCE Glide 3.x: DiskCacheStrategy.RESULT caches only the final image, after reducing the resolution (and possibly transformations) (default behavior of Glide 3.x)
  • Glide 4.x only: DiskCacheStrategy.AUTOMATIC intelligently chooses a cache strategy based on the resource (default behavior of Glide 4.x)
  • Glide 3.x & 4.x: DiskCacheStrategy.ALL caches all versions of the image

Further Read this

Yohannes Gebremariam
  • 2,225
  • 3
  • 17
  • 23