This blog has been moved. This redirect you our new blog with all old posts..

Cache problem in flex

How to avoid cache problem in flex? well guys i have tried it and i think it works. Put below script your main html file which contain swf file.

You can also put this script html-template/index.template.html. This will added automatically in you flex publish html file.

< Language="javascript">
var url = location.href;
var ots = parseInt(url.substring(url.indexOf("=")+1,url.length))+6000;
var dt = new Date();
var n = dt.getTime();
if(url.indexOf("?timeStamp=")!=-1)
{
if(isNumber(ots) && ots!=""){
if(nts>ots){
location.href=url.substring(0,url.indexOf("?"))+"?timeStamp="+nts;
}
}else{
location.href=url.substring(0,url.indexOf("?"))+"?timeStamp="+newTimeStamp;
}
}else{

location.href=url.substring(0,url.indexOf("?"))+"?timeStamp="+nts;
}
function isNumber(val)
{
var vc = "0123456789.";
var isNum=true;
var char;
for (i = 0; i < val.length && isNum == true; i++)
{
char = val.charAt(i);
if (vc.indexOf(char) == -1)
{
isNum = false;
}
}
return isNum;
}
</Script>

This script will generate a new query string for your application url in each refresh & which help to avoid cache problem.

No comments: