A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] [

  1. #1
    Junior Member
    Join Date
    Aug 2000
    Posts
    23

    Lightbulb

    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?

  2. #2
    The Supreme Shaman and Keeper of Polar Lights
    Join Date
    Apr 2000
    Posts
    1,175

    I love cut and pasting :)

    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]

  3. #3

    Re: I love cut and pasting :)

    ---
    Flash5
    Code:
    loadMovieNum ("name.swf?" add random(9999), 1);
    ---

    How can toy combine this with running the movie locally (i.e. hard drive)?

    I.

  4. #4
    Junior Member
    Join Date
    Aug 2000
    Posts
    23
    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.

  5. #5
    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!

  6. #6
    Junior Member
    Join Date
    Feb 2001
    Posts
    3

    Lightbulb youre a lifesaver

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center