Prevent XML caching problem

When load xml files by URLLoaders, they are often cached by the browsers and do flash is unable to display the updated data. This is a very common problem & I always find this some where around me once in a month or so. Even my friends do face the same issue.

There is a very simple solution to this cute little problem. When ever you are loading by URLLoader.load method just add a time stamp to the URLRequest and everything will work fine except you might get some error message while compiling the swf.(“Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL”). You can ignore it and continue publishing. On the web it will not throw any such error- believe me.

Here is the little rabbit:

  1. var xmlPath:String="replaceYourXMLPathHere.xml"
  2. var urlReq:URLRequest = new URLRequest(xmlPath+"?time=" + new Date().getTime());

Let me know if the readers have some other idea..

This entry was posted in AS3. Bookmark the permalink.

10 Responses to Prevent XML caching problem

  1. attonbomb says:

    Thank you so much this has been seriously twisting my melon for quite a while.

    God Bless

  2. Ellouze Ahmed Said says:

    Thank you very mutch ! :)
    this helped me to get out of a serious problem..

  3. ZenekZezool says:

    Thank You so much! I couldn’t find any answer why my php request gives me always the same data despite I update rows in database! Now it’s working ;)

  4. Derek says:

    Thank You

  5. Kikuk.Eling says:

    Thank You so Much .. !!
    this helped me to get out of a serious problem here.

  6. Richard says:

    Saved the day!!! I just can’t seem to remember this problem exists. Thanks for reminder!

  7. david says:

    very useful workaround, worked like a charm, thanks a lot for sharing :)

  8. Vladimir says:

    It works excellent. Now I can go to sleep. I spent couple hours to find out problem, and several minutes to fix it.
    God bless you.

  9. Sergey says:

    Just use POST. The content is not caching when you use it.
    var urlReq:URLRequest = new URLRequest(xmlPath);
    request.method=URLRequestMethod.POST;

  10. Sergey says:

    I make a mistake. Correct code:
    var urlReq:URLRequest = new URLRequest(xmlPath);
    urlReq.method=URLRequestMethod.POST;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>