I have an AS3 application running in flash player which aims at refreshing an image stored on a server. On every 1 second, the server replaces the image by a new one.
To get the image from server and not from cache, I had to add to use the random number method as shown below:
loader = new URLLoader();
var request:URLRequest =
new URLRequest(
"http://www.theServer.com/myImage.png?random"+(Math.random() * 10000));
loader.load(request);
, and the whole refreshing process works.
But what is annoying is that this method generates temporary files in the temporary folder which is growing and growing:
C:\Users\MyName\AppData\Local\Microsoft\Windows\INetCache
Is there a way to disable the cache as it is possible to do with Air? I am asking this because the application is to run on an embedded platform with flash player 10, on which there might be no way to access to flash player settings.
Regards.
Thanks for the hint Vesper, I finally found one way to disable cache for both AIR and actionscript:
function loadURLWitoutCaching(theURL:String):void
{
var _imgLoader:Loader = new Loader();
_imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
_imgLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoadingError);
var header:URLRequestHeader = new URLRequestHeader("pragma", "no-cache");
var request:URLRequest = new URLRequest(theURL);
request.data = new URLVariables("cache=no+cache");
request.method = URLRequestMethod.POST;
request.requestHeaders.push(header);
try {
_imgLoader.load(request);
} catch (error:Error) {
trace("Unable to load requested document.");
}
}
private function onLoadingError(e:IOErrorEvent):void
{
// Do something
}
private function onLoadComplete(evt:Event):void
{
// Do something
}
I am not sure the "URLVariables" is mandatory but it seemed to help.
Now I can't see any more mages being cached in "C:\Users\myName\AppData\Local\Microsoft\Windows\INetCache" folder.
Have a good day.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With