Set cache to files in Firebase Storage

前端 未结 5 888
爱一瞬间的悲伤
爱一瞬间的悲伤 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:00

    Use Serviceworker for that.

    You can save the urls without the token in cache and fetch them later.

    This way changes in tokens will not affect you caching.

    To cache without token, use something like

    cacheUrl = url.origin + url.pathname.substr(0, url.pathname.length - urlPath.length) + urlPath;
    

    and then cache.put(cacheUrl, response);

提交回复
热议问题