最简单的方法是在源字符串后面附加一些随机参数,该参数在服务器端会被忽略
<script src="https://www.mshxw.com/skin/sinaskin/image/nopic.gif" ></script>
一种解决方案是使用Javascript生成脚本元素,并像这样添加当前时间:
var el = document.createElement( script );el.src = 'mySaveFiles.json?nocache=' + (new Date()).getTime();document.head.appendChild( el );
这样,浏览器将永远不会缓存JSON文件,因为在每次调用中它似乎是一个不同的文件(由于参数)。



