Hi !
One more (and last) time :) :
It is possible to stop caching using .swf-s CGI output with hearders like
print "Content-type: application/x-shockwave-flash\r\n";
print "Cache-Control: no cache\r\n";
print "Pragma: no cache\r\n";
.....
and writing
<PARAM NAME=movie VALUE="name.cgi">
in HTML code
But there is one more natural way - just write in HTML code something like
<PARAM NAME=movie VALUE="name.swf?somethingrandom">
and
<EMBED src="name.swf?somethingrandom"
So, if you have small Flash page and want to force refreshing your .swf file frome server after every update, just edit HTML code after updating .swf files and add something like
<PARAM NAME=movie VALUE="name.swf?upd=15.01.2001">
and
<EMBED src="name.swf?upd=15.01.2001"
And to make flash movies always reload from server is enough to add something random for each visitor after "?" after swf name.
It is possible to generate this random string using for example JavaScript
Code:
<script language="JavaScript">
<!--
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
+' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"'
+' ID=name WIDTH=480 HEIGHT=216>'
+' <PARAM NAME=movie VALUE="name.swf?' + new Date().getTime() + '"> <PARAM NAME=loop VALUE=false>'
+' <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high>'
+' <PARAM NAME=bgcolor VALUE=#FFFFFF> '
+' <EMBED src="name.swf?' + new Date().getTime() + '" loop=false menu=false quality=high bgcolor=#FFFFFF '
+' WIDTH=480 HEIGHT=216 TYPE="application/x-shockwave-flash"'
+' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
+' </EMBED></OBJECT>');
//-->
</script>
using PHP
Code:
<?php
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
srand((double)microtime()*1000000);
$randval = rand();
?>
<html>
........
<PARAM NAME=movie VALUE="name.swf?<?echo $randval;?>">
......
<EMBED src="name.swf?<?echo $randval;?>"
or using ASP
Code:
<%@ Language=VBScript
Response.CacheControl="no-cache"
Response.AddHeader "Pragma","no-cache"
Response.Expires=0
randomize
rand_n=int(rnd*9999)
%>
........
<PARAM NAME=movie VALUE="name.swf?<%=rand_n%>">
......
<EMBED src="name.swf?<%=rand_n%>"
and if you load that movie using load movie action, you must say:
Flash5
Code:
loadMovieNum ("name.swf?" add random(9999), 1);
and Flash4
Code:
Load Movie ("name.swf"&Random (9999), 1)
If you want to prevent from caching load variables actions, use same way:
Flash5:
Code:
loadVariablesNum ("script.php?" add random(9999), 0);
and at last if you want to send variables using GET or POST without caching (yes, browsers cache it sometimes) while loading variables, just add random variable before sending :)
Flash5:
Code:
somename = random(9999);
loadVariablesNum ("script.php", 0, "GET");
Or POST :)
Hope it will help :)
[Edited by Ilya on 01-18-2001 at 07:08 PM]