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

后端 未结 6 2249
执笔经年
执笔经年 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条回答
  •  渐次进展
    2020-12-02 23:45

    Just in case others may come across the same issue. some of the solutions provided here (namely storing the cache info in a local browser data storage) could break for two reasons. Firstly if cache of the image expires and secondly if the cache is cleared by the user. Another approach would be to set the source of image to an placeholder. Then changing the source to the image path/name. This way it becomes the responsibility of the browser to check its own cache. Should work with most browsers regardless of their API.

提交回复
热议问题