How to prevent image caching?

3 posts

Flag Post

I have a swf which displays a tournament table, and there is a refresh button. First I load a .png like this:

var loading:Loader = new Loader();
var tournament:URLRequest = new URLRequest("http://myLink/image.png");
loading.load(tournament);

After refresh button is clicked it loads png again:

loading.load(tournament);

Then i add this png again, everything works, but it loads a browser cached image, is there a way to avoid this, maybe somehow to trick a swf to make it think that each URLRequest is unique?

 
Flag Post

One of the possible decisions would be to slap a random at the end of the URI.

var tournament:URLRequest = new URLRequest("http://myLink/image.png?random="+Math.random().toString());

 
Flag Post
Originally posted by vesperbot:

One of the possible decisions would be to slap a random at the end of the URI.

var tournament:URLRequest = new URLRequest("<a href="http://myLink/image.png?random=&amp;quot;+Math.random().toString()" rel="nofollow">http://myLink/image.png?random=&amp;quot;+Math.random().toString()&lt;/a&gt;);

Thank you that will work. However i tested with many different images and found out that this doesn’t work with all servers, images from some servers aren’t loading if you put ?+random number at the end of the link (while in flash), it works in a browser though. But thanks, that will do.