我怎样才能迫使window.location会做一个HTTP请求,而不是使用缓存的? [英] How can I force window.location to make an HTTP request instead of using the cache?

查看:113
本文介绍了我怎样才能迫使window.location会做一个HTTP请求,而不是使用缓存的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的web应用程序我设置 window.location的导航到不同的页面,但由于某些原因的Firefox显示了一个老版本的页面。

In my web application I am setting window.location to navigate to a different page, but for some reason Firefox shows an old version of that page.

用Firebug我发现,浏览器甚至不发送HTTP请求,它只是使用该页面的旧版本(即使不是最后一个),并显示它。

Using Firebug I detected that the browser doesn't even send an HTTP request, it simply uses an older version of that page (not even the last one) and displays it.

页面本身有所有常用的头以prevent缓存,当我使用浏览我的网页它完美的作品链接或手动输入。只有塞汀 window.location的

The page itself has all the usual headers to prevent caching which works perfectly when I browse my pages using links or manual input. The problem only occurs when seting window.location.

这是一个Firefox的问题或一些从任何浏览器的期望?可这种行为改变?

Is this a Firefox problem or something to expect from any browser? Can this behaviour be changed?

推荐答案

您可能只是为了让浏览器发出新的请求添加一个随机参数的页面URL。

You could just add a random parameter to the page URL in order to have the browser issue a new request.

因此​​,而不是使用

 window.location = "my.url/index.html";

使用

 window.location = "my.url/index.html?nocache=" + (new Date()).getTime();

这篇关于我怎样才能迫使window.location会做一个HTTP请求,而不是使用缓存的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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