Matt BurelloMatthew Burello
How To Prevent Caching of *.swf Files Using ColdFusion

SWFs, like other documents and media retrieved by a Web browser, are often saved, or cached, locally on the user's hard drive. The next time that media is requested the Web browser may load the file from the cache instead of downloading it over the network. This might be desirable for a Flash movie whose content doesn't change often but undesirable for SWFs that are updated frequently with new content or information.

Using the following techniques, SWFs can be forced to expire immediately from the Web browser's cache or the browser can be forced to re-download the media upon a given time interval.

This is the code that places a SWF file named "main1.swf" into an HTML document:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=",0,29,0" width="724" height="650">
<param name="movie" value="main1.swf">
<param name="quality" value="high">
<embed src="main1.swf" quality="high" pluginspage="" type="application/x-shockwave-flash" width="724" height="650"></embed>
After the first viewing of this page, the file "main1.swf" is stored in the browser's cache and not redownloaded on subsequent visits. To make the browser redownload the SWF we must trick the browser into thinking that it is downloading a different SWF file. To do this, we simply append a unique value to the file name in the "movie" param of the above code.
<param name="movie" value="main1.swf?UniqueID=<CFOUTPUT>#CreateUUID()#</CFOUTPUT>">

However, this causes the SWF file to be redownloaded on every visit. This may be desirable on pages that change constantly, but for most SWF files it is not necessary to redownload the file on every visit.
Let's say, for example that you only want the SWF file to be redownloaded on a daily basis. To do this, we will simply make the "UniqueID" we appended above a date string.

<param name="movie" value="main1.swf?UniqueID=<CFOUTPUT>#DateFormat(Now(), "mmddyyyy")#</CFOUTPUT>">
You could also use the same technique for any time period you like. For example, if you wanted the SWF to refresh monthly you would use the following code:
<param name="movie" value="main1.swf?UniqueID=<CFOUTPUT>#DateFormat(Now(), "mmyyyy")#</CFOUTPUT>">
Latest Innovations