首页 > 解决方案 > 如何在浏览器中加载缓存的图像

问题描述

实际上,我有一个网站需要时间从 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;

});

});

我只想使用缓存的图像并在下次加载网站时使用它。

标签: javascriptjqueryfirebasefirebase-storage

解决方案


推荐阅读