开发者

How can a flex mxml file being run on server as swf/html file be made non cachable?

I have a application developed in flex deployed on server. In the application data is filled by user and saved in cookies so as to be available even when the user closes the application. However if new version of application is released the user can still access the older version saved in the cahe. How can it be assured that whenever a new version of application is released the application is loaded from the server and not from the cache and at the same time data saved in the older version (in cookies) can also be accessed in the new version. Any pointers of accomplishing it using html, flex or py开发者_StackOverflowthon will high helpful.

Thanks


Easy enough, you just need a unique query string at the end of the swf file:

<object width="550" height="400">
<param name="movie" value="somefilename.swf?key=<ADD RANDOM NUMBER HERE>">
<embed src="somefilename.swf?key=<ADD RANDOM NUMBER HERE>" width="550" height="400">
</embed>
</object>

How you create that random number is up to you, but you need to use a server side language to do it (like php) and the number I normally use it just a timestamp.


The random querystring idea is a good way to make sure the swf is downloaded everytime, but that might not be what you really want to do. Especially if your swf is large in size and it only occasionally needs to update. What I would do is have a service that outputs the most recent version number of my swf. You'll have to come up with a version scheme that works for you (could be an svn build number for instance). When the swf build number changes, the new swf gets downloaded to the web browser. This would be accomplished by having your old swf make a service call early in the load process, if it finds a swf build number newer than its own, it would make a javascript call to the web browser causing the swf to be reloaded, appending a new value onto the source url (using the random querystring technique). The javascript call would be made using ExternalInterface.call (in Actionscript).

With this approach you can have your swf be cached until a newer swf is available for download, which will save your users bandwidth and load/bandwidth of your server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜