如何使用JavaScript和基本脚本加载强制不缓存 [英] How to force no cache using javascript and basic script loading

查看:84
本文介绍了如何使用JavaScript和基本脚本加载强制不缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小书签,该小书签始终使用 http://www.imvu-e.com/products/hpv/download/HPV.js 的缓存版本。我希望它从不缓存它并总是重新加载它。

I have a bookmarklet that keeps using cache versions of http://www.imvu-e.com/products/hpv/download/HPV.js. I want it to never cache it and always reload it.

这是我用来保存书签的超链接(用户将其拖动到安装书签的浏览器工具栏上):

This is the hyperlink I use to save the bookmarklet (which users drag to browser toolbar that installs it):

<a href="javascript:(function(){
     c = document.createElement(&quot;script&quot;);
     c.type = &quot;text/javascript&quot;;
     c.src = &quot;http://www.imvu-e.com/products/hpv/download/HPV.js&quot;;

     c.onload = c.onreadystatechange = function()                    {
            if ( ! (d = this.readyState) || d == &quot;loaded&quot; || d == &quot;complete&quot;){
                document.documentElement.childNodes[0].removeChild(c);
                version='beta';
            }
     };
     document.documentElement.childNodes[0].appendChild(c);
})();">Run HPV</a>


推荐答案

在网址末尾添加一个无用的查询字符串:

Add a useless querystring to the end of your url:

c.src = "http://www.imvu-e.com/products/hpv/download/HPV.js?" + (new Date).getTime(); 

这篇关于如何使用JavaScript和基本脚本加载强制不缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆