本地测试中缓存的 XML
我的问题是关于 XML 加载的。我需要避免 xml 缓存。
在 Web 服务器上,该技术是添加随机参数以在每次 XML 文件时重新加载。 但在本地测试中(在 Flash CS4 IDE 中,CTRL + Enter),以下几行是不可能的:
var my_date : Date;
path = "toto.xml?time="+my_date.getSeconds()+my_date.getMilliseconds();
有什么技巧可以绕过这个问题吗? 我在不同的论坛上读到过有关“删除”方法的内容,我们删除 xml 对象,然后重新创建一个新对象。
就我而言,我输入: myXML = null; myXML = 新 XML (loadedData);
但这根本不起作用。
我发现了一些有趣的东西,但不幸的是 Air 1.0 的 cacheResponse
。 在AS3中我发现:
var loader : URLLoader = new URLLoader();
var urlRequest : URLRequest = new URLRequest( xmlUrl );
var header : URLRequestHeader = new URLRequestHeader ( "pragma", "no-cache" );
urlRequest.requestHeaders.push(header);
但它不起作用。
我花了很多时间来解决这个问题,如果有人有好的解决方案...... 谢谢。
My question is about XML loading. I need to avoid xml caching.
On a web server, the technique is adding a random param to reload each time the XML file.
But on local testing (in Flash CS4 IDE, CTRL + Enter), the following lines are not possible :
var my_date : Date;
path = "toto.xml?time="+my_date.getSeconds()+my_date.getMilliseconds();
Is there any trick to bypass this issue ?
I've read on different forum about the "delete" method, we delete the xml object and then recreate one new.
In my case, I put : myXML = null; myXML = new XML ( loadedData );
But it doesn't work at all.
I found something interesting but for Air 1.0 unfortunately with the cacheResponse
.
In AS3 I found :
var loader : URLLoader = new URLLoader();
var urlRequest : URLRequest = new URLRequest( xmlUrl );
var header : URLRequestHeader = new URLRequestHeader ( "pragma", "no-cache" );
urlRequest.requestHeaders.push(header);
But it doesn't work.
I spent many hours on that problem, if anyone has a good solution...
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最近,我开始使用调试代理,它可以让我完全禁用缓存,但在我这样做之前,我使用了这个小动作脚本片段来处理这个问题:
Recently I've started using a debug proxy that let's me disable caching altogether, but before I did that I used this little actionscript snippet to deal with this issue:
主要的巨魔,但是:Pragma 不是控制缓存的最佳选择。花一些时间研究缓存:http://www.mnot.net/cache_docs/#PRAGMA
毕竟,在 URL 查询字符串的末尾添加一个随机数仍然是解决缓存问题的可靠方法。
Major troll, but: Pragma isn't the best option for controlling cache. Take some time to study caching: http://www.mnot.net/cache_docs/#PRAGMA
And after all that, adding a random number to the end of the URL querystring is still a surefire way of get past all that monkeybusiness with caching.