DylanVann / react-native-fast-image

🚩 FastImage, performant React Native image component.
MIT License
8.1k stars 1.48k forks source link

No way to clean cached images #197

Open rowinbot opened 6 years ago

rowinbot commented 6 years ago

Hi, I've seen a lot of issues around here about the cache, but I'm having issues with an app I'm developing, when you are able to log in, have a home screen with your avatar, but then when you change the avatar (it keeps the same url, only the image itself change) it doesn't reload because of the cache. I'm not able to provide inmutable url so currently don't know what to do, any help please?

It would be great if you provide a method to clean cached images so I can call it when the user logs out or re-run the app.

DylanVann commented 6 years ago

The main advantage of this package is that it does more aggressive caching.

If you want to clear the cache every time then you may as well just use Image. In your case I think it would be better to add a cache control property for that specific image.

rowinbot commented 6 years ago

How do I so?

DylanVann commented 6 years ago

A cache control property isn't currently a feature but I'm open to PRs. It would be better than clearing the whole cache each time.

As far as an immediate solution for you:

I think either of those would be fine.

n1ru4l commented 6 years ago

@DylanVann What about implementing a method for busting the whole cache (for development environments).

FibreFoX commented 5 years ago

http://bumptech.github.io/glide/doc/caching.html#clearing-memory

// This method must be called on the main thread.
Glide.get(context).clearMemory();

Maybe instead of using url-manipulations, there should be some API where the developers can trigger these cache-purges themselves 😃 of course with a lot of "you might not want to use this"-warnings around 😸 I'm actually fighting against some caching-issue where I want to use this library, but have no control over the HTTP headers the server is sending to me, therefor when having a cached image, and via a different workflow change that image (like profile-image upload in my app), the URL stays the same, so having a way to evict that image from cache, should be available (I think).

DylanVann commented 5 years ago

I'd be open to adding:

guhungry commented 5 years ago

@DylanVann #425

luatnd commented 5 years ago

I'd be open to adding:

Thanks, it would be nice to see these features! Is #425 of @guhungry good?

lucasfeijo commented 4 years ago

I'm having issues because fast-image cached invalid images during an s3 outage and now won't download the correct versions unless the url changes, which it won't because the url I use redirects to the real url, so I can't do the bust parameter approach. I would love a way to clear all cache.

cuongnm2301 commented 3 years ago

I'd be open to adding:

Any update, i having problem with caches too

akunal1 commented 3 years ago

A cache control property isn't currently a feature but I'm open to PRs. It would be better than clearing the whole cache each time.

As far as an immediate solution for you:

  • Use Image.
  • Use FastImage, but manually bust the cache yourself using a query parameter (uri: http://example.com/example.png?bust=123, where you change 123 each time you need to bust the cache).

I think either of those would be fine.

if my query params changes will it bust the cache of that particular image automatically or we have to do manually ? if manually how to do that.

thangpq commented 1 year ago

Why no answer like that?

FastImage.clearDiskCache(); FastImage.clearMemoryCache();

lorenjohnson commented 1 year ago

I was here for a little while wondering how in the heck do I clear the cache during development. I initially thought @thangpq that your response was saying, that these methods SHOULD exist and it took me a minute to realize they do exist!

Long story short, after a careful read through IMHO this issue could be closed. Thanks for the library! Been super helpful in our app.

nandha-kumar-hajari commented 1 year ago

Why no answer like that?

FastImage.clearDiskCache(); FastImage.clearMemoryCache();

This actually worked for me