Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

flash no-cache issues 1

Status
Not open for further replies.

sysadmin42

Technical User
May 6, 2005
138
I have a flash program that loads a directory listing (specifically for playing music) that a user can click on. My problem is, if the files in the directory change, the only way I can get that listing to refresh is by manually clearing the cached files. Most users have no idea how to do that manually.

How can I get the SWF to keep from caching? I've tried the following:

Code:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate, max-age=5">
<META HTTP-EQUIV="Expires" CONTENT="Fri, 26 Mar 2004 01:40:42 GMT"> <!-- also Expires: -1 -->

---- and/or ----

header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("cache-control: no-store, no-cache, must-revalidate"); header("Pragma: no-cache");

Any ideas?
 
You will need to load the external file via a script like in ASP. The trick is to add a random number at the end of the URL and fool flash into thinking it's a new file. For example:

To load the file I would call
loader.asp?Filename=dir.txt&RandomNumber=458298374

Build the URL in actionscript, creating a random number at the end.

This should at least get you going in the right direction.
 
I'm not quite sure what you mean. Where should I put the random number and the url?
 
What I do is add the random number to the end of the Flash element.

Example (using PHP):
Code:
swf/menu.swf?<? echo rand();?>

That way, you are sort of tricking the browser into thinking it's a different file every time because it will load menu.swf?38283 or menu.swf?92848, and so on.

frozenpeas
--
Micfo.com Affiliate Program
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top