通过 HTTPService 动态加载 .XML 文件时禁用缓存?

发布于 2024-10-13 05:57:40 字数 1001 浏览 2 评论 0原文

这是我的第一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感情洁癖 2024-10-20 05:57:40

我不是一个安静的 Delphi 或 Flex 人。但原理是一样的。我们在 C#/Silverlight 中所做的就是在 url 末尾附加一个随机查询字符串。

因此,如果您有 url :-

httpService.url = urlVar;

您会想要执行以下操作:-

httpService.url = urlVar + 'Date=' + currentdatetimealongwithmilliseconds;

这绝对应该忽略缓存并发出新请求。

注意:- 正如我所说,我不是 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 :-

httpService.url = urlVar;

you would want to do :-

httpService.url = urlVar + 'Date=' + currentdatetimealongwithmilliseconds;

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.

一枫情书 2024-10-20 05:57:40

在编辑代码时,我注意到一个语法错误。括号的数量不匹配。我认为应该有一个括号,我使用您的代码添加并加粗了一个括号?

我不知道这是否会解决您的问题,但是消除代码中的任何错误可以缩小问题范围:

private function loadXMLData(urlVar:String) { // <== HERE?
    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) {
    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) {
    var xmlList: XMLList;
    xmlList = XML(evt.result).Events;
    ArtistsData = new XMLListCollection(xmlList);
}

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.:

private function loadXMLData(urlVar:String) { // <== HERE?
    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) {
    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) {
    var xmlList: XMLList;
    xmlList = XML(evt.result).Events;
    ArtistsData = new XMLListCollection(xmlList);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文