Simon_Weaver
Simon_Weaver

Reputation: 145980

Preventing Flex application caching in browser (multiple modules)

I have a Flex application with multiple modules.

When I redeploy the application I was finding that modules (which are deployed as separate swf files) were being cached in the browser and the new versions weren't being loaded.

So i tried the age old trick of adding ?version=xxx to all the modules when they are loaded. The value xxx is a global parameter which is actually stored in the host html page:

var moduleSection:ModuleLoaderSection;
moduleSection = new ModuleLoaderSection();
moduleSection.visible = false;
moduleSection.moduleName = moduleName + "?version=" + MySite.masterVersion;

In addition I needed to add ?version=xxx to the main .swf that was being loaded. Since this is done by HTML I had to do this by modifying my AC_OETags.js file as below :

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf?mv=" + getMasterVersion(), "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

This is all fine and works great. I just have a hard time believing that Adobe doesn't already have a way to handle this. Given that Flex is being targeted to design modular applications for business I find it especially surprising.

What do other people do? I need to make sure my application reloads correctly even if someone has once per session selected for their 'browser cache checking policy'.

Upvotes: 8

Views: 13788

Answers (5)

user349449
user349449

Reputation: 11

here is sample.

  function AC_FL_RunContent(){
    var ret = AC_GetArgs(arguments, ".swf?ts=" + getTS(), "movie", 
              "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",
              "application/x-shockwave-flash");
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);  
  }

  function getTS() {
    var ts = new Date().getTime();
    return ts;
  }

AC_OETags.js is file and it exists html-template several places. but as my posting said, I am facing another type of problem.

Upvotes: 1

Stuart
Stuart

Reputation: 176

I had a similar problem, and ended up putting the SWF files in a sub-directory named as the build number. This meant that the URL to the SWF files pointed to a different location each time.

Ideally this should be catered for by the platform, but no joy there. But this works perfectly for us, and integrates very easily into our automated builds with Hudson - no complaints so far.

Upvotes: 3

Scott Evernden
Scott Evernden

Reputation: 39926

What I have done is checksum the SWF file and then add that to its url. Stays the same until the file is rebuilt/redeployed. Handled automagically by a few lines of server-side PHP script

Upvotes: 1

Theo
Theo

Reputation: 132862

The caching is not done by Flash Player but by the browser, so it's out of Adobe's control. I think you have found a workable solution. If I want to avoid caching I usually append a random number on the URL.

Upvotes: 0

Related Questions