views:

157

answers:

3

Hi,

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.

A: 

Did you ever figure this one out? If so, please share. This issue is kicking my butt!

Bootsified
I'm sorry I didn't find any solution to this issue. So if you find something, I'd be glad to hear from you.
Boun
A: 

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:

import flash.system.Capabilities;

var url:String = "foo.xml";
if (Capabilities.playerType == "StandAlone" || Capabilities.playerType == "External") {
    // running locally, cache busting not required
} else {
    // running in browser
    url += "?rnd=" + Math.random();
}
grapefrukt
A: 

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.

Sold Out Activist