Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I preload only images that are not in the cache ? #1006

Closed
osemen-remit opened this issue Feb 26, 2016 · 4 comments
Closed

How do I preload only images that are not in the cache ? #1006

osemen-remit opened this issue Feb 26, 2016 · 4 comments
Labels

Comments

@osemen-remit
Copy link

I'm trying to pre-fetch some images for better performance on some screens with preload() method. But I'm not sure if it invalidates items that are already in the cache. I would like topreload these items only if they are not in the cache as I know that image is not changed as long as url is the same but docs does not say anything about this.

Could you please clarify this ?
Thanks.

@TWiStErRob
Copy link
Collaborator

Which one do you want to preload the original image or the resized image that will be shown?

For SOURCE cache: use .downloadOnly()
For RESULT cache: I suggest ListPreloader

Glide assumes the same, the data doesn't change as long as the url is the same.

@osemen-remit
Copy link
Author

As images might be used in different places it's better to cache original images. But as they might not be bigger than screen I'm scaling then to screen size in order to save some space on disc. But it seems that it does not read preloaded images if thay are scaled to different size than ImageView requires. For instance most of images are 1440x2560 but a lot of devices have 1080x1920 so there is a big overhead by saving raw image. But if I scale it to 1080x1920 and than load it into view 1000x1000 it seems it does not take image from cache.

@TWiStErRob
Copy link
Collaborator

TWiStErRob commented Mar 3, 2016

These sounds really abstract operations, can you please share your Glide snippets? But before you do, try to check why the cache is not hit: https://github.com/bumptech/glide/wiki/Debugging-and-Error-Handling#debugging-workflow

Note that SOURCE cache doesn't store raw images, it stores the original, and if it's a compressed JPEG, they it stays that way.

Note that this kind of speculation and size handling is one of the strength of Glide. You just throw stuff at it and it'll make sure it uses the least amount of processor and memory on account of a little disk space. If you have one size use the default RESULT caching; and if you load a single image multiple times in different views, use ALL caching.

@TWiStErRob
Copy link
Collaborator

Please reopen if you need more help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants