How to programmatically empty browser cache?

前端 未结 11 1015
迷失自我
迷失自我 2020-11-22 17:36

I am looking for a way to programmatically empty the browser cache. I am doing this because the application caches confidential data and I\'d like to remove those when you p

11条回答
  •  没有蜡笔的小新
    2020-11-22 18:07

    Here is a single-liner of how you can delete ALL browser network cache using Cache.delete()

    caches.keys().then((keyList) => Promise.all(keyList.map((key) => caches.delete(key))))
    

    Works on Chrome 40+, Firefox 39+, Opera 27+ and Edge.

提交回复
热议问题