开发者

How can I prevent XMLHttpRequest to cache requests without jQuery?

开发者 https://www.devze.com 2023-01-15 11:19 出处:网络
I have an webapplication which refreshs a table each minute from a xml-file. When I edit the content of the xml-file, the log of the script shows a \"304 Not Modified\"-Message when it try to get the

I have an webapplication which refreshs a table each minute from a xml-file. When I edit the content of the xml-file, the log of the script shows a "304 Not Modified"-Message when it try to get the current file. But the file is edited. If i refresh the xml-file http:/xx.de/test.xml in the browser, the webapplication also shows the edit.

How can i prevent, that t开发者_如何学JAVAhe request will be cached?


If you set the header to:

header(“Pragma: no-cache”);
header(“cache-Control: no-cache, must-revalidate”);
header(“Expires: Mon, 12 Jul 2010 03:00:00 GMT”);

It should force it not to cache, if that's what you're after?


Two solutions from me:
1) add unique attribute like time to URL. So it will be like test.xml?x=840234242
2) set approriate headers in requested file.

0

精彩评论

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

关注公众号