Ted Patrick > { Events & Community } > Adobe Systems


Flex 3 Framework Caching

One of the new features in Flex 3 and Flash Player (MovieStar) is support for framework caching. Framework caching provides 2 things:

1. Separate the Flex framework from application code via Runtime Shared Libraries (RSL).
2. Installing a secure (signed) Flex framework RSL into Flash Player 9 release 3 (MovieStar)

When you separate the Flex framework into an RSL your application then depends on that RSL and it must be loaded when your app starts up. The RSL contains a specific version of the Flex Framework depending on Flex SDK you use. All sub-versions of Flash Player 9 support RSL but in last release (release 3) Adobe added support for caching a signed (.SWZ) version of the Flex framework. The caching logic installs the signed RSL into the player so that it can be used by Flex app on any domain. This basically allows the RSL to extend the Flash Player so that the Flex Framework version is never downloaded again. The first time a Flex application is used, the caching will occur, the N+1 time the user on any domain will only download the application logic.

Here are two example projects:

Framework cache disabled (default)
Properties/Flex Build Path/Library Path/Framework Linkage/ Merged into code


AC_OETags.js - ( JS Player detection )
playerProductInstall.swf ( Player upgrade SWF )
SampleProject.html ( Base HTML )
SampleProject.swf ( Application SWF file )

Framework cache enabled
Properties/Flex Build Path/Library Path/Framework Linkage/Runtime Shared Library (RSL)


AC_OETags.js - ( JS Player detection )
playerProductInstall.swf ( Player upgrade SWF )
SampleProject.html ( Base HTML )
SampleProject.swf ( Application SWF file )
framework_3.0.189825.swf ( Flex Framework RSL - Loaded for FP9r1 & FP9r2 players )
framework_3.0.189825.swz ( Signed Flex Framework RSL - Loaded for FP9r3+ )

Q: How will this work when a new SDK is released?

The key is that your app is dependent on a specific version of the Flex framework and the caching mechanism supports this. If you run into 2 apps built with different version of the Flex framework, say release and hotfix 1, both frameworks will get cached. This avoids the DLL hell issue typically in deploying windows applications. As the runtime manages caching and supports multiple version of the framework, it just works.

Q: How much smaller?

The signed Flex framework RSL (.SWZ) is 535KB and includes all base components and libraries in Flex. Even if your app uses just a button, the same SDK will get cached. A simple hello world application is 50KB vs the typical 350Kb. Size of your base application will vary depending on the components used as all skinning, style, assets, and custom code will be compiled into this base SWF file.

Q: Does this work with all Flash Players?

YES! Applications where framework caching are turned on will work in all release versions of Flash Player independent of the caching feature. Caching will occur automatically if Flash Player 9 release 3 or higher is installed.

Q: Can I cache custom code in the framework cache?


NO. Only signed Adobe components can be added into the Flex caching feature at this time due to data security. As the cached code is cross-domain enabled, anything in the RSL is added into the security domain of the running application.

Take a deeper look at Flex framework caching it is a great new feature in Flex 3. It will make your applications smaller and they will instantiate faster.

Regards,

Ted :)

13 Responses to “ Flex 3 Framework Caching ”

  1. # Anonymous Dan Schultz

    Quick question based on the following assumption: the framework SWZ is 535KB. Why isn't the framework SWZ broken down into 3 separate components? One for the main framework components (i.e. buttons, lists, containers, etc), and one for the charting framework, and another for the RPC framework? A lot of Flex apps out there do not use the charting framework for example.

    I understand that in most situations, people will probably have already downloaded the framework by the time they visit your app; however, you could still have shaved ~150kb (rough estimate :-) ) for the certain people that haven't yet visited a Flex site.

    Another suggestion, throw a hidden Flex app on the Flash Player installer page.  

  2. # Blogger Ted Patrick

    Dan,

    I need to get more detail into what is in the SWZ file. I am not sure that Flex Charting is in there.

    Let me get some detail and report back.

    Ted :)  

  3. # Blogger Ryan Campbell

    What if I'm including languages other than the included English and Japanese in the framework? Is the original signed framework SWZ file still used?  

  4. # Blogger Michael

    Great post Ted. Let's say you have one SWF you have rolled out that uses a SWZ. Now you want to release second SWF, but you want it to use the same SWZ. Is there anything special to be done, or is treated just like any other RSL?  

  5. # Anonymous Anonymous

    I wonder how big the cache on the client is?

    When new versions of the SDK are produced, say 2.01, 3, 4, 5, etc... how many are cached? When the cache is full, will it begin to overwrite the oldest cache data?  

  6. # OpenID James Ward

    Dan: There is a separate SWZ/RSL for the charting components and the RPC libraries. Also you can see what is in a SWC by unzipping it and looking at the catalog.xml file. So to see what is in the framework RSL just locate the framework.swc file, unzip it and take a look at the catalog.xml file. I hope that helps.

    Ryan: The language specific stuff is not in the framework RSL. There are additional SWCs which contain the resource bundles for the languages the Flex SDK supports. Those are compiled into your application.

    -James  

  7. # Blogger ctcmbz

    if the user has an earlier version of Flash and tries a swf that needs flash player release 3, from an embed tag for swf download, how does the end user get prompted to update the player?

    Right now, I see the following message displayed.

    "Flex Error #1002: Flash Player 9.0.60 and above is required to support signed RSLs. Problem occurred when trying to load the RSL framework_3.0.189825.swz. Upgrade your Flash Player and try again."  

  8. # Anonymous Dan Schultz

    Thanks for the explanation James. I figured you guys (Adobe) would think this through ;) Although I'm still a little amazed by the sizes. here's the breakdown for anyone who wants to know:

    framework: 523kb
    data visualization (charts): 276kb
    rpc: 117kb

    ctcmbz: to have the flash player do an update, go to your project's properties, and under Flex Compiler, there are two check boxes:

    - Change "Require Flash Player version" to: 9.0.60
    - Use express install (allows for a seamless player update to the end user)  

  9. # Anonymous Anonymous

    Why is the framework*.swf twice as big the framework*.swz? They should contain the same content,the Flex Framework, with the diference that one times the framework is signed and in the other case not.  

  10. # Anonymous Rich Butler

    They aren't.

    framework_3.0.189825.swz is 522kb
    framework_3.0.189825.swf is 520kb

    If you have a massive framework SWF file, you probably need to run it through the optimizer: http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs

    Cheers
    Rich  

  11. # Anonymous vacak

    Great post.  

  12. # Blogger pd

    Hello ted,

    can we rebuild the framework.swf again. well i recent ally changed the source code of flex framework now i am not able us that with out new framwork.swf , Do you have any idea how to rebuild the flex framework.swf file.  

  13. # Blogger Arulmurugan

    When ever I compile a proj/application the SWF I saw didn’t reflect any of the changes I’d made.

    I need to clear the cache, history, cookies in the browser.

    How to over come this.  

Post a Comment



Jobs


Flex Jobs
city, state, zip


© 2008 Ted On Flash