news-android icon indicating copy to clipboard operation
news-android copied to clipboard

use okhttp client for caching (instead of glide)

Open David-Development opened this issue 2 years ago • 2 comments

This MR disables Glides Caching and uses OkHttp's caching instead. The reason is that Glide does not care about ETags and Last-Modified Headers. Once a URL is in the cache it stays there. See: https://github.com/bumptech/glide/issues/1847

Fixes https://github.com/nextcloud/news-android/issues/1247

Changes:

  • Glide cache is now only 10mb as it is supposed to be used only for favicons
  • Default DiskCacheStrategy is now NONE - only favicons override this setting
  • OkHttp has a Cache now (which has the size of what's configured in the app settings - by default 500mb)

TODO:

  • Offline caching of images does not currently work (see todo in code)
  • Injecting images into articles from cache currently does not work (as the cache check only checks the glide cache - not the okhttp cache)

David-Development avatar Sep 30 '23 15:09 David-Development

@tobiasKaminsky FYI - I saw that you were involved in the dicussion in https://github.com/bumptech/glide/issues/1847. I think by using the OkHttp Client we can get around the issues with ETags / Last-Modfied without having to initiate a separate http request. But then again... this requires OkHttp which you are not using in the files app yet, eh?

David-Development avatar Sep 30 '23 15:09 David-Development

Nice idea! On Files we slowly switch to okhttp3, so this can then be a way to go.

tobiasKaminsky avatar Oct 13 '23 06:10 tobiasKaminsky