Post-loading : check if an image is in the browser cache

后端 未结 6 2324
执笔经年
执笔经年 2020-12-02 22:57

Short version question : Is there navigator.mozIsLocallyAvailable equivalent function that works on all browsers, or an alternative?

Long ve

6条回答
  •  旧时难觅i
    2020-12-02 23:31

    In 2017, Resource Timing API can help you check this using PerformanceResourceTiming.transferSize property. This property shall return non-zero transfer size when it is downloaded from server (not cached) and returns zero if fetched from a local cache.

    Reference : https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/transferSize

提交回复
热议问题