Link to home
Start Free TrialLog in
Avatar of slovisa
slovisa

asked on

Force SWF files to refresh with page, not load from cache

I'm working on a Flash portfolio that dynamically loads JPGs from a folder. Users can upload new files to the folder. Only problem is that (using IE) if you go back to the player page after uploading, it displays the previously cached SWF and you don't see the newly uploaded images. I'd like to force the page to re-upload the revised SWF.

Looking through EE, Macromedia support and MS support, I've seen several claims that adding these to the header will solve the problem:

<META HTTP-EQUIV="Expires" CONTENT="Mon, 04 Dec 1999 21:29:02 GMT">  (any old date)
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">

Of course, I'm posting to EE in a panic because these lines are apparently NOT preventing IE from displaying the cached SWF and I'm under the gun to get this fixed.

The slideshow is on a plain ol' HTML page, not dynamic.

I'm "just a designer," not a programmer, and not very advanced when it comes to ActionScript. Can someone provide a *simple* fix? This must come up all the time, but I haven't found a simple solution that works yet...

Thanks!
Avatar of CyanBlue
CyanBlue
Flag of United States of America image

Howdy...

If your page is static, the only option I can think of is using the JavaScript to generate an unique number to append to the SWF file name like this...  You will need to use document.write() to append the variable like that...

<SCRIPT LANGUAGE="JavaScript">
<!--
now = new Date().getTime();
//document.write(now + ' <br> ');
//-->

document.write('<OBJECT ... ... ');
document.write('<param name="movie" value="FIle.swf?rnd="' + now + ' />');
</SCRIPT>

CyanBlue
Avatar of slovisa
slovisa

ASKER

This looks like a good solution - I've tried something similar in ActionScript, using a loader swf to add a variable to the loadMovie parameter. Didn't have much luck with that, but I would definitely like to try this method.

I don't know much about JS. I've tried inserting this in my page, both literally and trying to add/replace my specific object and movie names. Either way, it breaks my page. What might I be doing wrong?
You won't see much difference if you are applying that technique on loadMovie() function if you have only one SWF file you are keep reloading...
If you are trying to initiating the loadMovie() function each time with different argument, you could try this...

now = new Date();
loadMovie("some.swf?uniqueID=" + now.getTime());

Let me know how it goes...  ;)

CyanBlue
Avatar of slovisa

ASKER

Again, I'm no programmer by any means... I don't even know if that's JavaScript or ActionScript. Can you tell me specifically what to place where, and what I need to change aside from the name of the swf?
Um...  Okay...  You said this...

'using a loader swf to add a variable to the loadMovie parameter.'

Can you show me the script that you have to achieve that???

CyanBlue
Avatar of slovisa

ASKER

The JavaScript solution would be fine, if you could explain it to me.

If ActionScript would be easier, here are three loader methods I found online. None of them has worked for me:

unique=new Date().getTime();
this.loadMovie("portfolio1.swf?list=10&unique="+unique);

noCache = Number(new Date());
loadMovieNum("portfolio1.swf?noCache=" + noCache, 1);

loadMovie("filename.swf?Ran" + random (99999999), target_mc);

Thanks for your help!
Hm...  Maybe there is something else going on in your code...  As far as I can tell, any of what you have should work fine to load the fresh portflio1.swf everytime... (and JavaScript solution is not what you are looking for in this case because you are talking about multiple SWF files whish should be taken care of from within the Flash...)

Do you have the site up somewhere where I can take a look???

CyanBlue
Avatar of slovisa

ASKER

Well, I haven't implemented any of these solutions since they're not working, but here is the SWF in action (with no loader/random variable swf mediating...just the main SWF): http://www.bringneworleansbackuic.com/group4/

The slideshow itself is a standard Flash MX component called load_images.FLA, found in the samples folder - but we modified it to read the images dynamically. It calls a file called "count.php" to read all the JPEGs that have been uploaded to a certain directory, then displays all of the images (rather than a fixed number, as it does "out of the box").  The idea is that users can upload their own images, then go back to the viewer and see them in the slideshow. The slideshow starts with the most recently uploaded image. But, since IE reads the SWF from cache, users don't see the newly uploaded images at all unless they clear their cache.

Let me know if seeing that in action helps. I would be happy to upload a page that uses one of those random variable loader solutions, but it doesn't turn out looking any different.

(If you test the upload function, please use a very benign image. It is live and others will be looking at it. I can delete your images later.)

Thanks again.
So, you don't actually have multiple SWF files to play with...  and you are reloading the SWF file any time you upload the image...  Then, JavaScript is going to be the one you will need to use...  Try this...

Find this block and comment them out...

<object type="application/x-shockwave-flash" data="portfolio4.swf" width="504" height="335">
<param name="movie" value="portfolio4.swf" />
</object>

Replace them with this block...

<SCRIPT LANGUAGE="JavaScript">
<!--
now = new Date().getTime();
//-->

document.write('<object type="application/x-shockwave-flash" data="portfolio4.swf?now="' + now + ' width="504" height="335">');
document.write('<param name="movie" value="portfolio4.swf?now="' + now + '" />');
</SCRIPT>

and see if this works...

Oh, if you can, add a small textField at the bottom of the page with the variable name set to 'now' and republish the SWF file...  If you do that, you are sure to know, since it is visible, that that value gets passed & changed when the page loads next time...

CyanBlue
Avatar of slovisa

ASKER

Well, I implemented your changes (minus the textField at the bottom) but:
     (a) it breaks the page, and
     (b) I'm guessing that it might not work because I manually uploaded a new image via FTP (since the upload link is missing) and the image does not appear in the slideshow when you refresh the page. (It does appear if you clear your cache, then refresh.)

Here is the revised page: http://www.bringneworleansbackuic.com/group4/jstest1.php

Any other ideas?
Well...  I think this is pretty much what I can do to help without going over what you have... (Or my JavaScript is not that great...  :D)

If you want, you can send me the appropriate files(jstest1.php, portfolio4.swf, count.php) and I can take another peek at it, but that's up to you...

Just out of curiosity, what is the connection between you and the UIC???  :)
I was attending UIC for several semesters and moved to Columbia College in downtown but I lived five minutes from the UIC for four years while I was in Chicago...  Good old days...  :)

CyanBlue
Avatar of slovisa

ASKER

Sure, if you're willing to look at the files I can send them. It would be much appreciated. What's the best way to get them to you?

Sorry to say there's no real connection between me and UIC, other than I'm helping someone put this mini-site together. I'm a Champaign-Urbana grad, though, and have lived in or near Chicago all my life.
You can find my email address if you check my profile...

Well...  I am now living in VA, so Urbana Champaign sounds fairly close...  :D

I cannot promise to fix this but I sure can take a look, so send me the files...

CyanBlue
ASKER CERTIFIED SOLUTION
Avatar of CyanBlue
CyanBlue
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of slovisa

ASKER

Fantastic. That does it!