实际上,我有一个网站需要花一些时间从Firebase服务器检索用户个人资料图片,我想知道是否可以通过某种方式缓存图像并在下次加载该网站时使用它。
我用于从firebase检索图像的代码是-
firebase.database().ref("/" + uid).child('userId').on('value', function(snapshot){
var storeTheUserId=snapshot.val();
var storageRef=firebase.storage().ref();
var setTheChild=storageRef.child(storeTheUserId + '.png')
setTheChild.getDownloadURL().then(function(url){
document.getElementById('userProfilePicture').src=url;
});
});
我只想使用缓存的图像,并在下次加载网站时使用它。