Closed anshul-kai closed 7 years ago
I just asked myself the same thing. Made an experiment, where I used prefetch
to download a very large image from the exact same url. When running the app inside iOS Simulator and having the Debug navigator open, where you can see the 'Network' tab, I could see that it's loading the image every time, prefetch
is called.
So, the function may cache the image for later usage. But it's not "intelligent" enough to decide wether the image exists in the cache or doesn't.
Thanks for sharing your insight @eneskaya. How are you able to see network requests in debug mode?
I will look further into prefetch.
Thanks @jayesbe. I wasn't able to verify @eneskaya's comment above as I'm still struggling logging my network requests. I do know that Image.prefetch
doesn't fetch the image again within the same session of the app. It may not be persisting to disk if I had to make a guess.
A promise based prefetch in this library would be great to have.
The network requests can bee seen, when you run the app within iOS Simulator or on device in debug mode:
Then when I use Image.prefetch
to fetch a very large image in a setInterval
I can see, that every time a request is made.
Thats the result using Image.prefetch
in a setInterval
Thanks for sharing @eneskaya. I had forgotten about the Network info in XCode and was beating myself up with making it work in Chrome.
Your observation is inline with mine. Image.prefetch
does fetch and cache the image for use in an Image
component. Multiple renders of such an Image
component use the same cached image but calling Image.prefetch
again fetches the image from the remote.
You're welcome 😄 This issue can be closed then I think.
Yes, I'll go ahead and close it. @jayesbe it'll be great to have the ability to prefetch
a CacheableImage
to avoid the ActivityIndicator
.
@a-koka I agree a prefetch would be helpful. Will give it some thought.
Just wondering if this lib offers anything over
Image.prefetch
? I realize thatImage.prefetch
is relatively new and this lib may have been introduced back in the day to overcome that limitation.