5 Replies Latest reply on May 24, 2006 10:16 AM by abeall

    anti cache XML

    abeall Level 3
      I've long known the old timestamp query string trick for anti caching, but never really had to worry about with XML.load in Flash. I just now tried it:

      myXML.load("myxml.xml?timestamp="+escape(new Date().toString()));

      And it gives an error: failed to load file. If I remove the timestamp, it works. In other words, the ?timestamp= makes Flash think the file doesn't exist. I did some googling and found dozens of answers to "how to stop caching of XML" and they all said to use the query trick; however I am experiencing that a query string throws off the XML file name. Anybody know about this?
        • 1. Re: anti cache XML
          ogousa-swS9lV
          try

          myXML.load("myxml.xml?cacheKiller=" + getTimer());

          it works for me
          • 2. Re: anti cache XML
            blemmo Level 1
            Are you testing this locally? If so, it won't work, because your system will look for a file that has the exact name, including all after the ?, and won't find it. However, a decent webserver handles filenames in a different way, ignoring the ? stuff when searching for the file. For local tests, just comment out the cache killer part.
            If this happens when testing online, the webserver you use is misconfigured, I'd guess. In that case you must tell it to treat names with a ? so that it ignores the ? part when looking for the file.

            greets,
            blemmo
            • 3. Re: anti cache XML
              Rothrock Level 5
              Crazy that great minds must be thinking alike. I just ran into this very problem late on Saturday night. And I hadn't had a chance to work out the details. Thanks for the help.
              • 4. Re: anti cache XML
                Level 7
                This should work.

                myXML.load("myxml.xml" + (_url.indexOf("file") == 0 ? "" :
                "?timestamp="+escape(new Date().toString()) ) );



                "abeall" <webforumsuser@macromedia.com> wrote in message
                news:e51q3l$oci$1@forums.macromedia.com...
                > I've long known the old timestamp query string trick for anti caching, but
                > never really had to worry about with XML.load in Flash. I just now tried
                it:
                >
                > myXML.load("myxml.xml?timestamp="+escape(new Date().toString()));
                >
                > And it gives an error: failed to load file. If I remove the timestamp, it
                > works. In other words, the ?timestamp= makes Flash think the file doesn't
                > exist. I did some googling and found dozens of answers to "how to stop
                caching
                > of XML" and they all said to use the query trick; however I am
                experiencing
                > that a query string throws off the XML file name. Anybody know about this?
                >


                • 5. Re: anti cache XML
                  abeall Level 3
                  > Are you testing this locally?
                  Right on, blemmo. I was testing locally. Problem solved.

                  In addition to working on a webserver, it appears to work in locally if viewed in a browser, just not in the SAPlayer.

                  > (_url.indexOf("file") == 0 ? "" :
                  Clever. Thanks!