开发者

How to force ie9 browser to read xml from server and not from cache [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

For anyone who is struggling with how to get ie9 to read an xml file from the server, and not from cache, here's a simple solution. If you are able to modify the html page which is loadin开发者_StackOverflow社区g the xml using javascript and XmlHttpRequest, you can use a hidden iframe to force the xml to load when the page is refreshed. For example, somewhere in the html page, add the following:

    <iframe src="myfile.xml" width="0" height="0" style="display:none"></iframe> <!--resolves xml caching issues-->

Hope this helps. It may not be the best solution since it causes another get from the server, but I searched and searched and tried various header setting combinations such as xmlhttp.setRequestHeader("Cache-Control", "no-cache") and nothing worked in ie9! ie8 would read the xml from the server if you closed the browser and reopened it. But ie9 simply will not (at least not from my godaddy server). So with this method, you can simply refresh the page, and the xml will be read from the server every time. ie9 seems to have really applied caching to the extreme to where it's making it difficult to get fresh data. I use godaddy hosting, I'm not sure if that adds further issues - maybe due to proxy servers.

Hope this helps. Mark


Tack on a random number to the file name:

myfile.xml?rand=12345


Karolis and cwolves solutions are much better... If I had the "reputation" points, I'd up them.

In fact it's used quite consistently, even by MS in their AJAX/WebResource implementations, except they usually append t=YearMonthDayHour24MinutesSeconds to their requests.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜