admin管理员组文章数量:1405153
Javascript provides the location.reload(nocache)
API.
When the 'nocache' param is true, it will force reload the current url from server bypassing the browser cache.
Is there an equivalent way to do this when navigating to a new url via window.location.href = url;
?
I have a chat application which detects the version the client is running pared to what the server expects, and if they differ it prompts the client to navigate to the latest version url.
But I'm finding when I issue this, many clients are still using cached scripts.
Javascript provides the location.reload(nocache)
API.
When the 'nocache' param is true, it will force reload the current url from server bypassing the browser cache.
Is there an equivalent way to do this when navigating to a new url via window.location.href = url;
?
I have a chat application which detects the version the client is running pared to what the server expects, and if they differ it prompts the client to navigate to the latest version url.
But I'm finding when I issue this, many clients are still using cached scripts.
Share Improve this question edited Oct 16, 2016 at 8:57 Nurjan 6,0936 gold badges37 silver badges56 bronze badges asked Oct 16, 2016 at 7:54 carpiicarpii 2,0114 gold badges21 silver badges25 bronze badges1 Answer
Reset to default 8There's no out of the box solution. The easiest way is to add another parameter to the URL that will break the cache. For example
window.location = "/server/url?timestamp=" + (new Date()).getTime()
Every single time you run it, the timestamp will change and the browser won't have that page in the cache.
本文标签: navigate to new url in javascriptbut force reloadStack Overflow
版权声明:本文标题:navigate to new url in javascript, but force reload? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744887738a2630587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论