Actually browser caching mechanism is very useful but sometimes it might be chaotic
especially when new version of applications is avaliable. Cached artifacts likes swf should automatically cleared on the client machines when new version of the application avaliable. The way i solve this problem may not be the best but it works. So here i share it. If you have other solutions please share,
When you get new realese, you should add build number where swf object embedded in your html pages. It will be cached until you assign a new realese number.
You can automatize this in your continuous integration environment defining a ant job that assigns a realese where swf objects embedded.
In Adobe Flex applications,mxml compiler (mxml) uses index.template.html file shown below to produce swf and to embed it to application's main html file. So if you add a query string parameter after ${swf}.swf in this javascript prevents swf caching.
To check if this works, write "about:cache?device=disk" in address bar of your firefox browser you will see your swf object with a new query string that means it has forced the browser to make request for the this swf object .
<script type="text/javascript">
<!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->
var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
<!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
var xiSwfUrlStr = "${expressInstallSwf}";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "${bgcolor}";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "${application}";
attributes.name = "${application}";
attributes.align = "middle";
swfobject.embedSWF(
"${swf}.swf?v=@@@", "flashContent",
"${width}", "${height}",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
<!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
swfobject.createCSS("#flashContent", "display:block;text-align:left;");
</script>
No comments:
Post a Comment