简体   繁体   English

是否可以使用javascript清除浏览器缓存?

[英]Is it possible to clear the browser cache using javascript?

Many times we clear user browser cache when a user open our website or we need user permission to do so. 很多时候,当用户打开我们的网站时我们会清除用户浏览器缓存,或者我们需要用户权限才能这样做。 However I spend some time on the internet to find any article or something about clearing the cache through javaScript but I did not find any. 但是,我花了一些时间在Internet上找到任何文章或有关通过javaScript清除缓存的内容,但没有找到任何文章。

No - JavaScript would not have permission to perform this sort of OS-level operation. 否-JavaScript将没有执行此类OS级操作的权限。 It is clearly something that only the user should be able to invoke, not a third-party script without their knowledge. 显然,只有用户才可以调用某些东西,而不是在他们不了解的情况下调用第三方脚本。

If you have issues with caching, there are approaches to force fresh loads, eg by adding random query strings to HREFs/SRCs. 如果您在缓存方面遇到问题,可以采用一些方法来强制执行新的加载,例如,通过向HREF / SRC中添加随机查询字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM