How can I prevent XMLHttpRequest to cache requests without jQuery?
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.
精彩评论