I am writing an app in react js using firebase as the backend service. The images names and location is stored in the realtime database and is accessed and then the file(image) is fetched from the cloud storage and displayed on the screen.
eg.
getFile(path){
firebase.database().ref('').child(path).once('value').then(snap =>{
cloudStorage.child(snap.val()).getDownloadURL().then(url =>{
this.setState({fetchedImage: url});
});
});
}
So the fetched image url is provided as a source to an image tag
<img src={this.state.fetchedImage}/>
Now the image renders after browser downloads it. So after it has downloaded and rendered, if I navigate away from the element and come back again, it will again re download this image. This increases the time taken to load up that element.
Can I download this and save this image to the web storage so that I download the image again when my view re-renders?
Thanks, Zeeshan