本文介绍了从浏览器缓存中删除单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的页面中有一个图像,该图像已缓存在浏览器中。
i have an image in my page, the image is cached in the browser.
现在我已删除该图像,但是由于已将其缓存,因此请求确实
now i have deleted the image, however Because it was cached, the request does not go to the server, And it appears again.
所以如何从浏览器缓存中删除它?
so How can I delete it from the browser cache?
推荐答案
否,您不能物理删除缓存的文件。相反,您可以动态生成到文件的链接,例如
No you cannot physically delete cached file. Instead you can generate link to the file dynamically, for example
<script type="text/javascript">
document.write('<img id="without-cache" src="image.jpg?v=' + new Date().getTime() + '" />');
</script>
并最终使用不同的?v = $ c $更改源c>当您要重新加载而不从缓存中加载它时。
and eventually change the source with different ?v=
when you want to reload it without loading it from cache.
$("#without-cache").attr("src", "image.jpg?v=" + new Date().getTime());
这篇关于从浏览器缓存中删除单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!