Is it possible to prevent a browser from caching a page, specifically a swf file? I want to use a flash file for bandwidth test, but if the files are cached I will get screwy results.
Any Ideas?
Printable View
Is it possible to prevent a browser from caching a page, specifically a swf file? I want to use a flash file for bandwidth test, but if the files are cached I will get screwy results.
Any Ideas?
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
using PHPCode:<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>
or using ASPCode:<?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;?>"
and if you load that movie using load movie action, you must say: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%>"
Flash5
and Flash4Code:loadMovieNum ("name.swf?" add random(9999), 1);
If you want to prevent from caching load variables actions, use same way:Code:Load Movie ("name.swf"&Random (9999), 1)
Flash5:
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 :)Code:loadVariablesNum ("script.php?" add random(9999), 0);
Flash5:
Or POST :)Code:somename = random(9999);
loadVariablesNum ("script.php", 0, "GET");
Hope it will help :)
[Edited by Ilya on 01-18-2001 at 07:08 PM]
---
Flash5
---Code:loadMovieNum ("name.swf?" add random(9999), 1);
How can toy combine this with running the movie locally (i.e. hard drive)?
I.
whats the point of preveneting caching on something stored on a hard drive? The access time is what 20/megs a sec? This means that even if you were to prevent caching, by the way there is no caching locally, then it would load faster than you could blink your eyes.
Sorry for not being clear enough...
Users of my swf use it both locally and via the internet. It's only the internet part where the caching needs to be disabled. That's the reasing for attaching the "random" part to the text file that's read.
The point is that this command doesn't work when running in local mode. And I'd like my swf to deal with both cases.
Please try again!
I have been looking all over for a way to call this from the swf/fla file...not from your html file. tried it and works perfectly, I have a ticker on my site that links to a text file. like i said, works great!!! Thank You
http://www.skatecity-elpaso.com