javascript - 如何在浏览器中加载缓存的图像
问题描述
实际上,我有一个网站需要时间从 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;
});
});
我只想使用缓存的图像并在下次加载网站时使用它。
解决方案
推荐阅读
- python - Python 多处理 - 如何使其更高效
- amazon-web-services - 从在 AWS 上运行的 Apache Nifi 访问 AWS 服务
- scala - 如果我将同步放在 isVisited 上,并行图遍历可以工作吗?
- mysql - 在第二个表MYSQL中按多行过滤数据
- google-apps-script - 谷歌电子表格自动时间戳:我在删除单元格内容时不想要时间戳
- reactjs - 当 fullWidth 为 true 时,TextField 不呈现
- swift - 具有相同案例名称和不同类型关联值的枚举
- ruby-on-rails - Posggresql 无法加载 hstore.so
- c++ - c ++有没有办法根据用户想要的输入数量输出多个输入
- java - OpenCV / Java 在 IDE 内工作,但不能从命令行(Windows、Netbeans、JavaFX 应用程序)