-
[RESOLVED] SWF Cache
Hi again,
So after finally being able to save information to a text file and retrieving it with many thanks to Flashkit, I was able to do some basics. However, the SWF is caching with IE and Firefox, but works perfectly fine in Chrome.
Anyways, looking online, someone said to add:
Code:
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
To your web page that's embedding the SWF, but it's not working. Is there an alternative fix?
-
That's going to prevent caching on your HTML document.
Caching shouldn't really be an issue with your SWF. By that I mean, caching is a good thing. You're probably not actually editing the SWF very often. You are now during development and testing. For that, it's best to just clear your cache manually with your browser.
Unless there's another reason you want it to NOT be cached?
-
Well the reason is that I am making a mini map editor that a few people are going to collaborate on building with the tools I provide. So if someone updates it, someone else can then just refresh and see the updated version.
It works in Chrome, just refreshing the page but in IE/Firefox it shows the older version.
-
I wouldn't make judgments based on what IE does. :P It doesn't do half of the things it should do correctly.
-
Haha, so I guess that would mean there's no actual way to not cache.
I read somewhere you could 'append' a random number at the end of your SWF to trick the browser into thinking it was a unique file, but no idea how that works.
-
Yeah, you can. Are you using swfobject to embed your SWF file?
-
I'm just using this in my HTML:
Code:
<object width="1000" height="600">
<param name="movie" value="Build.swf" />
<embed src="Build.swf" width="1000" height="600" </embed>
</embed>
</object>
I had used:
Code:
<meta http-equiv="pragma" content="no-cache" />
As I posted earlier. But it only works in Chrome. When I took it out, Chrome would start caching the older version too, so I left it in so I could at least test it myself. But I know many people don't use Chrome.
-
I did a little researching on swfobject, and downloaded it. I placed it into the same directory as my SWF on the FTP and inserted this code in HTML:
Code:
<script type="text/javascript" src="swfobject.js">
var so = new SWFObject("Build.swf", "mymovie", "400", "200", "8", "#336699");
so.useExpressInstall('expressinstall.swf');
so.write("flashcontent");
</script>
No luck, but it seems to be the same code all other websites are suggesting too.
EDIT: It appears I missed a line. I got it to work, so far. :)
-
With swfobject, it's easy to append a "cache buster" to the swf url. Basically, just appending a random string to the end is going to cause the file to not be cached, since on every request, it'll think it's a different file. Doing this will give you a filename like: Build.swf?2342
Code:
<script type="text/javascript" src="swfobject.js">
var so = new SWFObject("Build.swf?"+Math.round(Math.random()*10000), "mymovie", "400", "200", "8", "#336699");
so.useExpressInstall('expressinstall.swf');
so.write("flashcontent");
</script>
-
I also tried that this morning before I posted here, code doesn't seem to work. The layout of the FTP is this:
index.htm
swfobject.js
expressinstall.swf
Build.swf
Are all in the same directory. The HTML code is very simple as follows:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<title>FLASH TEST</title>
</head>
<body>
<script type="text/javascript" src="swfobject.js">
var so = new SWFObject("Build.swf?"+Math.round(Math.random()*10000), "mymovie", "1000", "800", "8", "#336699");
so.useExpressInstall('expressinstall.swf');
so.write("flashcontent");
</script>
</body>
</html>
Thanks a lot for helping me over this past week. Really appreciated. :)
-
You need to create a container for the movie to be drawn into. That's what so.write("flashcontent") means. It's trying to put it inside the object with an id of flashcontent, but you don't have one. So just modify your code like this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<title>FLASH TEST</title>
</head>
<body>
<div id="flashcontent"></div>
<script type="text/javascript" src="swfobject.js">
var so = new SWFObject("Build.swf?"+Math.round(Math.random()*10000), "mymovie", "1000", "800", "8", "#336699");
so.useExpressInstall('expressinstall.swf');
so.write("flashcontent");
</script>
</body>
</html>
-
Oh I was wondering what that was, I just thought it was something to do with the javascript. The website I was on earlier used the <div></div> container thing, but he also had a bunch of other stuff which was irrelevant and specific to his own project ... so I thought the container wasn't important too.
Anyways I included it in the html, but the page still appears blank. Is it because I need to set a size for the container?
-
Do you have a URL I can look at?
-
Yeah, don't mind the crappy imaging, I just need to make placeholders haha. Anyways, the URL is mattostil.110mb.com.
-
Wow, I didn't even notice: you're declaring your Javascript tag wrong. Try this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<title>FLASH TEST</title>
</head>
<body>
<div id="flashcontent"></div>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var so = new SWFObject("Build.swf?"+Math.round(Math.random()*10000), "mymovie", "1000", "800", "8", "#336699");
so.useExpressInstall("expressinstall.swf");
so.write("flashcontent");
</script>
</body>
</html>
-
Haha, good call. So it displays it now, but IE is still caching. I deleted the temporary files and it'll display the newest version. However, adding content, saving and then refreshing still shows the cache.
Actually now that I check, Chrome is caching now as well. Man, I have the worst luck it seems.
Anyways, you can check out the website now.
-
I see you're also loading in external txt files. THOSE are going to get cached. Your swf shouldn't be.
But again, if IE is the main culprit, ignore it. IE doesn't know what it's doing, and doesn't count as a browser.
-
SWEET, you're a genious! I appended a random number to the external text files in Flash when they loaded, and it works!
You've taught me a lot these past few days, I really appreciate it. Thanks for all the help, I'll be back if I need anything. I'm going to be tackling PHP/MySQL in the near future, so ... yeah, I'll be back.
:D
-
guyz .. guyz.. i just saw the view of work @Osteel.. Its awesome man..
I am really new in that cache concept .. can you guyz tell me where from i can learn the basic of cache..
how you save data and with 2 lines command in javascript..
please tell me..
thanks
-
I think you're confused. Osteel was trying to PREVENT stuff from being cached. Caching happens automatically in the browser. Nothing really to learn. It just... happens. Sometimes we want to work around the caching if a certain file changes frequently on the server.