美文网首页
禁止浏览器缓存策略

禁止浏览器缓存策略

作者: huanghaodong | 来源:发表于2020-09-05 14:28 被阅读0次
<html manifest="IGNORE.manifest">

以上设置需要网页刷新一次才能生效,下面代码可以实现打开强制刷新

if(!window.name){         
    var str = Math.random().toString(36).substr(2);//随机字符串 
    var S = getQueryString('S')
    window.name = 'isreload';     
    if (S) {
        window.location.href = window.location.href.replace(/^([^&]*)\?([^&]*)&?S=([^&]+)(\S*)$/, function(match,$1,$2,$3){
            return match.replace($3, str)
        })
    }else{
        if(window.location.search.indexOf('?') > -1){

            window.location.search += 'S=' + str;
        }else{
            window.location.search = 'S=' + str;
        }
    }
}else{
    window.name = ''
}
function getQueryString(name) {  
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");  
    var r = window.location.search.substr(1).match(reg);  
    if (r != null) return decodeURI(r[2]);
    return null;  
}

相关文章

网友评论

      本文标题:禁止浏览器缓存策略

      本文链接:https://www.haomeiwen.com/subject/ykqfektx.html