我通过flex向服务器查询,第一次它显示结果,但是当我下次插入新记录并查询时,它仅显示以前的结果(在IE中面临问题,但在chrome中则不然)。
最佳答案
您可以参数化您的 http(?) 请求,并通过设置始终更改的参数,您可以确保您的响应永远不会从缓存中读取。
在下面的示例中,我使用名为 nocache
的参数来执行此任务:
您可以在 URL 字符串中设置 nocache
参数:
var url:String = "http://data.your.server?nocache=" + new Date().getTime();
或者 - 如果您使用 URLRequest
,您可以将其设置在其数据成员中:
//the url from where you get the data
var url:String = "http://data.your.server";
var urlVars:URLVariables = new URLVariables();
urlVars.nocache = new Date().getTime();
//set the other parameters (if any)
//attach the parameter list to your request
var request:URLRequest = new URLRequest(url);
request.data = urlVars;
更新
这里 new Date().getTime()
将返回系统的当前时间(以毫秒为单位),这样您就可以确定,它不会再次使用此参数值调用。
关于apache-flex - Flex缓存问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5987715/