views:

106

answers:

3

When I deploy a new .swf file in an HTML file as shown below, I have to clear the browser cache before the new .swf file loads in the browser. Is there anyway to force the browser to load the .swf file when I replace it with a new one on the server.

<embed type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.adobe.com/go/getflashplayer" allowscriptaccess="sameDomain" name="Prototype" bgcolor="#869ca7" quality="high" id="Prototype" src="/flex/Prototype.swf"> 

Thanks, Chirag

+3  A: 

change the source name by tagging.

src="/flex/Prototype.swf?ver=1.0.1"
sheeks06
A: 

Just append a number within the query string (you might think of it as version number of sorts). Then change that number whenever you change your SWF. When the number changes, the browser will see it as a different URL, so it'll skip the cache and go back to the server for a fresh copy of the swf.

<embed 
   type="application/x-shockwave-flash" 
   wmode="transparent" pluginspage="http://www.adobe.com/go/getflashplayer" 
   allowscriptaccess="sameDomain" name="Prototype" bgcolor="#869ca7" 
   quality="high" id="Prototype" src="/flex/Prototype.swf?1234" > 
Lee
A: 

I do the same but add a random number so I don't have to write a new number every time

src="/flex/Prototype.swf?<?= rand() ?>"  
PatrickS
But with a random number, returning visitors will have to wait for the file to be downloaded from the server at every visit, regardless of if it is changed or not. So longer load times for returning visitors and large load on your server, right? With the version number approach, you can control when to allow cache and when to force an updated swf to be fetched.
Lars
i wouldn't use this for production purposes, only for development so i don't have to repeatedly clear the browser's cache . for production , it makes sense to use the version approach. i agree!
PatrickS