通过 HTTPService 动态加载 .XML 文件时禁用缓存?
这是我的第一个 CMS 应用程序,背景是 Delphi 7。
我使用 5 个不同的 XMLListCollections,它们是从服务器上的本地文件动态加载的。 HTTPService 将第一个文件加载到 DataGrid 中效果很好,但是在加载任何后续 XML 文件时,它会加载与之前完全相同的集合!我认为这一定是一个缓存?
加载本地 XML 文件时如何关闭缓存?我已经尝试过一些建议,例如涉及标头等,但似乎没有什么可以直接处理加载本地文件。
private function loadXMLData(urlVar:String):void
var httpService:HTTPService = new HTTPService();
httpService.url = urlVar;
httpService.resultFormat = "e4x";
httpService.addEventListener(FaultEvent.FAULT, httpService_fault);
httpService.addEventListener(ResultEvent.RESULT, httpService_result);
httpService.send();
}
private function httpService_fault(evt:FaultEvent):void {
var title:String = evt.type + " (" + evt.fault.faultCode + ")";
var text:String = evt.fault.faultString;
alert = Alert.show(text, title);
}
private function httpService_result(evt:ResultEvent):void {
var xmlList: XMLList;
xmlList = XML(evt.result).Events;
ArtistsData = new XMLListCollection(xmlList);
}
This is my first CMS application and in the ackground is Delphi 7.
I use 5 different XMLListCollections which are dynamically loaded from local files on the server. HTTPService loads the first one into a DataGrid just fine, but when loading any subsequent XML file, it loads the same exact collection as before! I assume this must be a cache?
How do I turn off caching then when loading local XML files? I have tried some suggestions already, like involving headers and so on but nothing seems to deal directly with loading local files.
private function loadXMLData(urlVar:String):void
var httpService:HTTPService = new HTTPService();
httpService.url = urlVar;
httpService.resultFormat = "e4x";
httpService.addEventListener(FaultEvent.FAULT, httpService_fault);
httpService.addEventListener(ResultEvent.RESULT, httpService_result);
httpService.send();
}
private function httpService_fault(evt:FaultEvent):void {
var title:String = evt.type + " (" + evt.fault.faultCode + ")";
var text:String = evt.fault.faultString;
alert = Alert.show(text, title);
}
private function httpService_result(evt:ResultEvent):void {
var xmlList: XMLList;
xmlList = XML(evt.result).Events;
ArtistsData = new XMLListCollection(xmlList);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不是一个安静的 Delphi 或 Flex 人。但原理是一样的。我们在 C#/Silverlight 中所做的就是在 url 末尾附加一个随机查询字符串。
因此,如果您有 url :-
您会想要执行以下操作:-
这绝对应该忽略缓存并发出新请求。
注意:- 正如我所说,我不是 Flex 人员,您需要在您的 Flex 解决方案中转换上述行。
I am not quiet a Delphi or Flex guy. But the principles the same. What we do in C#/Silverlight is append a random query string at the end of the url.
So where you have url :-
you would want to do :-
This should definitely ignore the cache and make a new request.
Note :- As i said i am not a Flex guy, you need to convert the above line in your flex solution.
在编辑代码时,我注意到一个语法错误。括号的数量不匹配。我认为应该有一个括号,我使用您的代码添加并加粗了一个括号?
我不知道这是否会解决您的问题,但是消除代码中的任何错误可以缩小问题范围:
Whilst editing your code, I noticed a syntax error. The number of brackets don't match. I presume there should be a bracket where I have added and bolded one, using your code?
I don't know if this will resolve your issue, but eliminating anything that is erroneous in your code narrows down the problem.: