PDA

View Full Version : Dynamic Text Cache



Templarian
May 9th, 2005, 06:22 PM
This might go under client side, but how would i make it so that the files I dynamically load into flash dont keep a cache.
I update the site though .txt files and its updated about every day and my friend just told me that it looks the same for him.

(i use firefox and deleting the history doesn't work).

virusescu
May 9th, 2005, 07:22 PM
Easy... for solving the cache problem read here - http://www.kirupa.com/developer/actionscript/tricks/cache.htm

Templarian
May 9th, 2005, 08:10 PM
says it cant find the file filename.txt?uniq=8172

virusescu
May 9th, 2005, 08:50 PM
and it's working without the ?uniq=283928 part ???

Templarian
May 9th, 2005, 08:54 PM
yea...
Error opening URL "......./config.txt?uniq=3290"

Templarian
May 9th, 2005, 08:56 PM
loadText = new LoadVars();
myIdentifier = Math.round(Math.random()*100000);
loadText.load("config/config.txt?uniq="+myIdentifier, 1);
loadText.onLoad = function() {
_root.sitename.html = true;
_root.sitename.htmlText = this.siteheader;
_root.rantamt = this.totalrants;
};

Templarian
May 10th, 2005, 04:41 PM
is there a easy example i could see. because i have know idea how to do this.
Thanks in advance.

virusescu
May 11th, 2005, 04:28 AM
Hello again. I didn't realized that you use LoadVars :P - you can't send variables like that unique identifier attach to the string like that. The variables in the loadVars object are sent automatically if you use a send and load method... somethin like this example

loadText = new LoadVars();
loadText.uniq= Math.floor(Math.random()*10000000);
loadText.sendAndLoad("outside.txt", loadText, "GET");

This wil actualy load an url like outside.txt?uniq=1238294
Because now you are sending something to the browser, the browser will be force to retrieve the info from the server because the actual result could change to reflect the information passed.

I usually use the post method. And by the way... the uniq variable passed does not even need to be that uniq. I mean if I pass the same string (attached to the loadVars)... load vars will still force the reload. For me it worked like this. If you want to make it uniq, then make it :P

I attached a simple example. Enjoy. Hope it helps you

Templarian
May 12th, 2005, 05:09 PM
?? Thats wierd. I tried your code, took about an hour or confusion to see that it wasn't me that was getting it wrong. The code doesn't work online, only off the HD.

I don't really know why it doesn't work so can u help me someone.

virusescu
May 12th, 2005, 06:39 PM
Sorry for your lost hour, I know how bad it is... anyway... have you tryed changeing the method to GET instead of POST?
I see that not all the servers work with this method.
I tryed it online you know... before posting the example, and it worked fine with me, but when you said something is wrong with the code, I tried it on a different server, and you were right, it didn't. But changeing the method form POST to GET in the sendAndLoad did the trick.
I don't know what's behind this issue...