GithubHelp home page GithubHelp logo

Comments (7)

kfiroo avatar kfiroo commented on May 23, 2024

@ramsestom If you know you want to force fetch a url you could remove it from the cache and reload your image, that should do the trick

from react-native-cached-image.

manjeets12 avatar manjeets12 commented on May 23, 2024

tried this but showing same image all the time even after it resolve successfully, I checked in browser and image is different

ImageCacheProvider.clearCache({cacheLocation: ImageCacheProvider.LOCATION.BUNDLE}).
    then(() => {
            console.log('cacheMultipleImages Done');
    })
    .catch(err => {
        console.log('cacheMultipleImages caught an error: ', err);
    });

from react-native-cached-image.

kfiroo avatar kfiroo commented on May 23, 2024

@manjeets12 If you are using the latest v1.4.0 release, you could use ImageCacheManager.deleteUrl to invalidate a single url from the cache and force the cache manager to download it again.

v1.3.5 had ImageCacheProvider.deleteCachedImage that did the same thing.

from react-native-cached-image.

vonovak avatar vonovak commented on May 23, 2024

@kfiroo the point here is that if user changes the image on the server, this package doesn't fetch the new image but instead uses the old one...

from react-native-cached-image.

kfiroo avatar kfiroo commented on May 23, 2024

@vonovak Thanks, that's why I suggested to use deleteUrl or deleteCachedImage to make sure the url will return the newly uploaded image and not the cached version :)

from react-native-cached-image.

vonovak avatar vonovak commented on May 23, 2024

sure @kfiroo but how can I tell whether or not the image on server has changed? - how to know whether I should call deleteUrl or deleteCachedImage? I could call it on every start, but that renders the cache useless. That's why @ramsestom suggested to have an option that would control how the caching works. For example, the package could make a HEAD request to the server to see if the locally stored image is out of date and download the new one if that is the case.. :)

from react-native-cached-image.

kfiroo avatar kfiroo commented on May 23, 2024

@vonovak The original issue here is about adding a forceFetch prop to the CachedImage which means you have to know (on the client side) that the URL is out-of-date and the image should be fetched again, and for that end I suggested the deleteUrl method.

You raise a good point, though. In the scenario where the image changed on the server and there is an old cached version in the client's app there is no way for us to know it.

I would generally suggest to use the CachedImage for static URLs of images that you don't want to bundle with your app so you can download them once and make the app feel faster.

Regarding "controlling how the caching works", the latest version actually has all cache login injected into to the ImageCacheManager so you can customize if however you like, I would love to get some feedback if you do decide to try that approach :)

from react-native-cached-image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.