3 Replies Latest reply on Nov 4, 2006 8:19 AM by leotemp

    Refreshing a URLLoader

      I'm using a URLLoader object to load up an XML file on creationComplete for the app.

      var externalXML:XML;
      var loader:URLLoader = new URLLoader();
      var request:URLRequest = new URLRequest("script.xml");

      private function completeHandler(event:Event):void {
      loader = URLLoader(event.target);
      externalXML = new XML(loader.data);

      function onAppCreationComplete():void{
      loader.addEventListener(Event.COMPLETE, completeHandler);

      Problem is, it seems the URLLoader is caching the XML file. So that, if I make any edits to script.xml, they are not reflected in the subsequent load. First, is this expected behavior? And second, if so, how to I force the URLLoader to clear it's cache so that it actually loads the data from the updated XML?

      Any insight would be appreciated.
      Thanks in advance,
        • 1. Re: Refreshing a URLLoader
          Im pretty sure you need to make any cache changes on the server via administration or server side script. You can however fool it by adding a random parameter to the url request that the browser ignores and the xml file cant use like url?randomgarbage=19873098732jhdskh983yqehdp that will fool it, however your best bet would be to use an HTTPService for that and bypass the problem completely.
          • 2. Re: Refreshing a URLLoader
            csteinhilber Level 1
            I realized I could add the cache-buster metatags to the HTML wrapper, and that seems to have done the trick.

            <META HTTP-EQUIV="EXPIRES" CONTENT="Sat, 01 Jan 2000 00:00:01 GMT">

            However... I'm interested in learning more about "using an HTTPService" to "bypass the problem completely". Everything I read suggested that URLLoader was the way to go for loading my local XML. How would HTTPService solve the problem?
            • 3. Re: Refreshing a URLLoader
              leotemp Level 1
              I was not aware you were loading your xml locally, If you are indeed pulling the data off the same client the app is running on then you can embed the xml directly in the app.

              <mx:XML id="myData" source="myData.xml" />