So I was working on a project, and realized I needed a way to update my application once it had been deployed. I figured the answer was simple:  add PHP headers to stop caching. Wrong.

That didn’t solve the problem at all.

So my next idea was, let me add random parameters onto my source SWF link to trick the browser into thinking data has changed and not load the cached file. This would be perfectly flawless except for the fact that nobody wants to re-download a 1 MB+ file every time they reload, especially if the user is on a dial-up connection.

So I stumbled across this Adobe article titled, “Providing Version Synchronization for Deployed Rich Internet Applications.” This fantastic article solves the problem entirely by creating a class in the Flex app that polls a server for the most recent “version number” allowing you to control the poll time and force the user to update their application.

Since that specific example is a little outdated, I just had to modify a few things, and was up and running in no time. My current application uses AMFPHP for it’s backend, so instead of connecting to a ColdFusion server as the article suggests, I just tapped into my AMF service in PHP, which just returns a string containing the latest version number; ie. 1, 1.5, 2.

So all you would do if the VersionManager realizes that the current user is on an outdated version is use navigateToURL and basically reload the page, but with an update parameter in the URL. Then in your PHP or JavaScript, just make sure you check if that update parameter exists, then append random parameters to your SWF source link and the browser will not load that file from cache 🙂

My updated can be found here, enjoy!