Prevent a SWF From Caching in Browser

To tackle preventing a swf from caching in a browser window without using cf, php, etc, I have the script below using javascript to generate the random number to append to the swf url. It would be good to hear if anyone has any other methods to handle this one or if there are any glaring flaws in a particular browser related to caching.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  
    <head>
        <title>No Cache</title>
        
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="Expires" content ="0" />
               <meta http-equiv="Pragma" content ="no-cache" />
               <meta http-equiv="Cache-Control" content ="no-cache" />
      
        <link href="styles.css" rel="stylesheet" type="text/css">
        
      <script type="text/javascript" src="swfobject.js"></script>
      
      <script type="text/javascript">
          var randomnumber=Math.floor(Math.random()*10000);
          var flashvars = 
          {  
              foo: "foo"
          };
          var params = 
          {
              allowfullscreen: false,
              bg_color: '#333333'
          };
          var attributes = {};
          attributes.id = "flashcontent";
          swfobject.embedSWF("index.swf?"+randomnumber, "alternativeContent", "500", "400", "9.0.115", "expressInstall.swf", flashvars, params, attributes);
      </script>
        
  </head>
    <body>
            
        <div id="alternativeContent">
                <p>This page requires the Adobe Flash player.<br>
                    <a href="http://www.adobe.com/go/getflashplayer">Download now.</a></p>
                <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
        </div>    
            
    </body>
</html>

Comments