url加时间戳方法及作用

速记:URL 的末尾追加了时间。这就确保了请求不会在它第一次被发送后即缓存,而是会在此方法每次被调用后重新创建和重发;此 URL 会由于时间戳的不同而稍微有些不同。这种技巧常被用于确保到脚本的 POST 每次都会实际生成新请求且 Web 服务器不会尝试缓存来自服务器的响应。

// 解决浏览器缓存的问题
function timestamp(url){
    var getTimestamp=new Date().getTime();
    if(url.indexOf("?")>-1){
        url=url+"×tamp="+getTimestamp
    }else{
        url=url+"?timestamp="+getTimestamp
    }
    return url
}
url.indexOf("?")>-1?`${url}×tamp=${new Date().getTime()}`:`${url}?=timestamp${new Date().getTime()}`

转载于:https://www.cnblogs.com/smart-girl/p/10534098.html

你可能感兴趣的:(爬虫,c#,python)