Set cache to files in Firebase Storage

前端 未结 5 905
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-18 18:57

I have a PWA running on Firebase. My image files are hosted on the Firebase Storage. I\'ve noticed my browser doesn\'t save cache for files loaded from the storage system. T

5条回答
  •  旧巷少年郎
    2020-12-18 19:13

    To complement the answer, you can also use a service worker, maybe with workbox, with a cacheFirst strategy to cache all images into the user browser. Then, after first cache, the images will be load from local cache first.

    If there's no cache, then the images will be requested from Firebase Storage, where the images can also be cached if you specified the cacheControl property in file metadata or if you is using Firebase Hosting with custom header Cache-Control for images.

提交回复
热议问题