tags:

views:

270

answers:

2

Hi,

I've created a Flex application and the size of the swf file is ~900KB.

My trouble is that the files are not getting cached. When I launch the application for the second time, the swf file is fetched again from the server.

I'm including the swf file in a jsp, and I'm not modifying any HTTP Caching Headers. I assumed that the swf files will be cached automatically. Isn't it so?

How do I forcefully cache the file? Do I need to provide anything in the MXML code or just a response.setHeader("Cache-Control","max-age=100"); is enough? Can anything be done from the flex side itself?

Suggestions please...

A: 

I would assume that the request for the SWF is separate from the request for your JSP page (just like requests for images are separate). Thus, you probably need to configure your server to serve SWF files with a specific cache header. I doubt changing the cache settings for the JSP page will make a difference.

rmeador
A: 

I presume you mean that your JSP page generates HTML which contains a reference to the SWF - this would be the common case. In this case, there are (at least) two HTTP requests made by the browser - one for the JSP page and one for the SWF file. As the SWF file is static, it may be served up by your J2EE server or by your webserver (e.g. Apache), depending on your configuration. You will need to check what cache settings are applicable to your static content (e.g. images) and ensure that those settings prevent caching of the SWF. Your JSP cache settings will only affect the HTML and not the SWF.

Ideally, browse your site using Firefox and Firebug and check the headers for each HTTP request (Firebug's Net tab). This should give you the information you need about what headers are applicable to the SWF.

Vinay Sajip