The SWF above is named index.swf. It loads a SWF named
test_cache.swf into a movieclip on the root of the main timeline. The test_cache.swf
has the arrow and the buttons.
The test_cache.swf is delivered via a PHP proxy page named
swf_proxy.php that loads the SWF from a file and sends it with HTTP headers.
The PHP code is below:
Some common places to look for the test_cache.swf file to
see if it was cached:
C:\Documents and Settings\*username*\Application Data\Mozilla\Firefox\Profiles\default.8wq\Cache
C:\Documents and Settings\*username*\Local Settings\Temporary Internet Files
C:\Windows\Profiles\*username*\Temporary Internet Files\Content.IE5
and look with command line for
C:\Documents and Settings\*username*\Local Settings\Temporary Internet Files\Content.IE5\*random*\
(the path above won't show up in Windows explorer even if you have it set
to show the "system files".. it's hidden unless you access via command
line)
I've tested this with IE 6 and Firefox 1.02 and it does
prevent caching into the "common" folders.. but.. I know it
won't prevent caching 100% of the time (some browsers ignore
the HTTP headers that control caching, etc.. and... .. dig around
a bit.. look for swf_proxy.swf, swf_proxy[1].swf, or swf_proxy[2].swf
..... sigh.. Microsoft is just plain scum. Even after the user
indicates "I
don't want to cache stuff", the web developer says "please don't
cache this file" and the web server says "don't cache this file"...
what does Windows XP and IE do? Cache it in a hidden folder.
yippee. I'm switching back to mac.
If you are able to find the
test_cache.swf in your browser cache or anywhere on your
system please contact
me and let me know what browser you are using, what version it is, what
version your Flash Player is, and your Operating System.
I've added an ASP version in here.. and it also shows how you can have one page that masks which SWF file is actually being requested. Even if you're using PHP take a look at the ASP file.
The example above is for preventing caching of the file
by using PHP code to send HTTP headers that instruct the browser
to not cache the file. You can also use CFML, ASP, etc.
You can also set IIS or Apache to apply the headers shown above
to an entire directory, etc. I've put some examples of that in my blog here
Trying to prevent the file from being cached on the clients system
is sort of a fruitless pursuit though since there are so many tools available
for snagging the SWF... and decompiling it.. the example above just "keeps
the honest folks out".. .. and Microsoft is going to cache that file to the supersecret hidden cache folder anyway.. sigh
But.. if you just want to keep fresh content
for your viewer and don't care if the file is cached on their
system then that's possible just by appending a random number
to the end of the request for the SWF such as mySWF.swf?somejunkvar=1234283736.
That way the browser will be forced to load a new version
of the SWF each time it is viewed. Read a great article about
this from Kenny Bunch here ((and note his note about using a shell or proxy SWF so the user doesn't have to load your giant SWF each time.. cache the important stuff and force them to not cache the data and shell..))
Also.. if you have a "parent" SWF loading a child
SWF and are hoping that the child SWF isn't normally
cached.. well.. both the parent and the child
are cached. Don't believe me? Try here