Web browser caching 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. The Purpose of Caching Caching is designed to speed up data loading. When a browser request data from a web server, it checks whether that data is already loaded previously and is still on the cache. If yes, then the browser might load from the cache instead of requesting the data again from the server (this avoids a re-downloading, which could be slow on a modem connection). The caching behavior is somewhat unpredictable. It depends on the browser, the user's cache-setting, and to some extent, the way the script is written, or even the server. For example, on Internet Explorer 5, user can set how large the cache is from Tools » Internet Options » Temporary Internet Files. For all practical purposes, it is impossible to predict whether a particular piece of data is being cached or not. Yes, we can use "pragma no-cache," and set the server to prevent caching, and so on. But these aren't reliable either, some browsers might still ignore these directives. 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 every attempt to access it. Note: The META tags used below will only work with browsers that support these tags. Use one or all of these methods to ensure SWF files are downloaded each time: Using the 'Expires' header. The Expires header of an HTML document tells a Web browser when a cached document should expire from the cache. Using a date in the past ensures the document will always be expired.Insert the text below between the <HEAD></HEAD> tags of the HTML document containing the embedded SWF. <META HTTP-EQUIV="Expires" CONTENT="Mon, 04 Dec 1999 21:29:02 GMT"> Each and every time this document is requested the browser will notice that the cached version has expired and will download the file from it's server of origin. Using the Pragma: No-Cache header. This code directs the browser to not cache the document at all. Insert the following text after the closing </BODY> tag of the HTML page containing the embedded SWF. <HEAD> <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> </HEAD> Note: the Pragma: No-Cache header does not work with Internet Explorer 5. Microsoft recommends using the Cache-Control header, instead. See Microsoft's article on this subject. Simply place a query-string operator, ?, followed by a number on the end of the link URL. in your <OBJECT> tag <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="700" HEIGHT="300" id="remote" ALIGN="middle"> <PARAM NAME=movie VALUE="/sandbox/remotessas/remotessas.swf?23"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="/sandbox/remotessas/remotessas.swf?23" quality=high bgcolor=#FFFFFF WIDTH="700" HEIGHT="300" NAME="remote" ALIGN="middle" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT> You can also change the extension of your HTML page to ASP and add the following code at the very beginning of your ASP page: <% Response.Expires = 1 Response.ExpiresAbsolute = Now() - 2 Response.AddHeader "pragma","no-cache" Response.AddHeader "cache-control","private" Response.CacheControl = "no-cache" %> To ensure that pages or variables called from withing Flash are not cached versions: instead of: getURL ("http://www.mxer.com/hello..asp"); do this: unique=new Date().getTime() //will always be unique getURL ("http://www.mxer.com/hello..asp?unique="+unique); |