JabbyPanda’s travel to RIA world / 35 posts / categories / 84 comments / feed / comments feed

mx:HTTPService calls are cached in IE 6 unnecessary

Usually, mx:HTTPService is defined in MXML in the following way:

<mx:HTTPService id="accountsRequest"
method="POST" url="accounts.php"
result="assignUsersData(event)" fault="onErrorLoad(event)">
</mx:HTTPService>

Such a HTTP request works flawlessly in Firefox browser, but in IE6 after first call the results of HTTP get cached and a new call to the remote destination never occur. The same issue is discussed at Adobe Flash Player 9 forums.My solution to prevent caching of HTTP requests in IE is to add foo variable to the url of HTTP Service that equals to the random value.

private function changePage(pageIdValue : Number) : void {
var rnd : Number = Math.round(Math.random()*1000);
accountsRequest.url = "accounts.php?foo=" + rnd;
accountsRequest.send();
pageId = pageIdValue; }

15 Comments

  1. judah — November 23, 2006 #

    Great tip! :)
    As you know, MXML is my preferred language. So I provided an example of your code using MXML. You can change the url attribute like so:
    url=”accounts.php?foo={Math.round(Math.random()*1000)}”

  2. another crappy blog » Blog Archive » Error #2032: Stream Error. — March 12, 2007 #

    [...] Another cause for this error in certain browsers is caching. Use JabbyPanda’s technique to prevent caching in IE6 or set the response headers in your server side page to prevent caching. [...]

  3. Bhasu — March 29, 2007 #

    Great Tip, Really useful as a quick solution!

  4. dre staes — May 8, 2007 #

    This is also happening in apollo.

    i’ve read in a comment on the adobe site by CNelissen that, for php, you have to use:

  5. dre staes — May 8, 2007 #

    i’ve read in a comment on the adobe site by CNelissen that, for php, you have to use:

    session_start();
    header(“Cache-control: private”);

  6. Kan — August 5, 2007 #

    It really helps us. The HTTP services error happens sometime in IE and we have no idea to solve this untill find this tip. Since we cannot control the behavior in the sever side which is an external one.

  7. levan — August 9, 2007 #

    you don’t need random at all just new Date() .toMiliseconds that it.

  8. Action Script Error Repository » Blog Archive » 2032 Stream Error. — June 28, 2008 #

    [...] cause for this error in certain browsers is caching. Use JabbyPanda’s technique to prevent caching in IE6 or set the response headers in your server side page to prevent [...]

  9. T Plack — December 20, 2008 #

    Turns out that the PHP session_start() sets the “no-cache” as well. Had to remove this for it to work.

  10. arunkumar — July 11, 2009 #

    really great tip!! it works fine …

  11. Reece — August 3, 2009 #

    I would use Date() .toMiliseconds as suggested by levan.

    There is a remote possibility that you may generate the same value twice with random (particularly if triggered at a regular interval). At least with Date() .toMiliseconds you can be absolutely certain then that the variable is a unique value.

  12. Reece — August 3, 2009 #

    Ant the way to get milliseconds is

    Date().valueOf();

  13. shrikant — October 1, 2009 #

    hi
    i am getting the same error in IE as well as Firefox. I am using URLStream to load a page from a server. I get the first response just fine but in the second response i get the stream error mentioned in the post. Also i m coding in AS3, does the suggestion still hold in my case? And I am not sure if I randomize the url, i will need to make changes on server side too ?

    I wasnt getting this error earlier, It used to work fine.
    Please shower your useful comments.
    Thanks

  14. a.panas — October 3, 2009 #

    Hi Shrikant,

    Yes my suggestion holds true also for fetching remote resources over HTTP by usong URLStream class

  15. Nilesh — July 15, 2010 #

    I used the date milisecond, which will always give me the new val and solved my problem!

    Thanks,
    Nilesh

Leave a comment

Powered by WP Hashcash