Preventing The Browser From Returning A Cached SWF

A quick little snippet using Coldfusion to avoid swf caching at the browser. Swf caching can be a real pain in the but during the development and it can also be annoying in production. When you make updates, you actually want to view them. Anyway, enough chit chat:

swfobject.embedSWF('myFlashApplication.swf?nocache=#CreateUUID()#', 'myDiv', '600', '480', '9.0.0', 'expressInstall.swf',{},{});

So the above snippet, using swfobject because it does the trick so nicely, shows that we are throwing a url parameter at the swf to be injects. Essentially, this does nothing at all. However, the Coldfusion CreateUUID() function will give us an easy-to-generate unique number every time and the unique param. The browser sees a unique url and will grab the swf anew each time.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Russell Brown's Gravatar I do a similar thing, although to help with performance I create an appKey in the application scope. Every time the application is restarted a new one is created.

I don't make important changes to an app without re-initializing it so this makes sure that 95% of the time people are getting a cached version and only forced to do a re-download if I've made changes.
# Posted By Russell Brown | 8/31/09 9:34 PM
jason olmsted's Gravatar For a stable environment, the appKey seems like a pretty nice way to ensure that everybody gets updated after infrequent updates. For development, however, I don't think that an application scoped key will be much help.

I think I am still inclined for the CreateUUID(), though I guess I ought to consider how much it taxes the server, but, as I muse over the appKey, there might be situations where it gives you a nice handle for auditing behavior.

Anyway, thanks for the comment.
# Posted By jason olmsted | 8/31/09 10:52 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001. Contact Blog Owner