开发者

How i can say browser to stop caching the mine page in Firefox?

开发者 https://www.devze.com 2023-03-16 10:52 出处:网络
I have a web-page where i load second page using jQuery ajax and page also load the css who i load from jQuery code instead of embeded html code [in head tag].

I have a web-page where i load second page using jQuery ajax and page also load the css who i load from jQuery code instead of embeded html code [in head tag].

the problem is that both Chrome and firefox does not refresh the partial page if i make something change.

in the partial page partial.html if i change something and make refresh none of them change them in chrome it's work using CTR开发者_JAVA技巧L +R but Firefox does not know that page goes changed they still produce the old things.

that's the problem i have. how i can told browser firefox to stop caching my page.


This problem is classically solved by changing the URL of the loaded data every time you use it. For instance, you could add a parameter of random data to the URL like this:

var url = "http://example.com/page.php?foo=bar&random=" + Math.random();

To create an URL that is different every time, but leads to the same data.


I always use a URL variable to fix caching issues e.g. :

var u = "http://www.nocacheplease.com/test.aspx?v=" + new Date().getTime();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号