# Script needed to remove SWF from cache

**URL:** https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461
**Category:** Uncategorized
**Created:** [January 17, 2003, 12:51pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461 "2003-01-17T12:51:52Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![runestar](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@runestar](https://forum.kirupa.com/u/runestar)
#### Post date: [January 17, 2003, 12:51pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/1 "2003-01-17T12:51:52Z")

</div>

Hi there!

I’ve made an SWF-movie that screws up when refreshing the site it appears in. The first time you enter the page it’s all ok, but when you refresh the page, or visit it again later in that session, it screws up completely, ignoring all of the different scripted “stop” actions. If you close the browser and open it again, the movie is allright.

I guess I need a script that removes the swf from the cache memory once it’s played one time.

Can anyone please help me with this problem. It’s kind’a urgent and Ireally don’t know where to find this script if not here…

Thanks in advance, guys!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 17, 2003, 5:49pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/2 "2003-01-17T17:49:28Z")

</div>

Hi,

As far as I know you can’t clear the user’s cache. That would be violating their personal settings.

I saw some code a while back that basically assigned a random extension to the back of the loadMovie(); command. I will have to send it to you tonight. It went something like this.

```auto

randomNumber = Math.random(10000);
_root.emptyMC.loadMovie("mymovie.swf?" + randomNumber);

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 17, 2003, 5:53pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/3 "2003-01-17T17:53:06Z")

</div>

[http://www.kirupaforum.com/showthread.php?s=&threadid=11610#post80797](http://www.kirupaforum.com/showthread.php?s=&threadid=11610#post80797)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 17, 2003, 6:01pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/4 "2003-01-17T18:01:30Z")

</div>

Thanks senocular,

I was trying to find that thread. I could not find it under my subscribed threads for some reason.

Thanks for answering this question one more time=)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 17, 2003, 6:28pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/5 "2003-01-17T18:28:42Z")

</div>

I just found this from another thread. It does the same thing as senocular’s code except it uses the time to make it unqiue.

Just thought I would share.

```auto

///////////////////////////////////////////////////////////////////////
// Prevents caching of loaded files (TXTs, SWFs, XMLs etc...)
// Source : www.layer51.com
// Author : sam at nseir dot com
String.prototype.noCache = function() {
	if ((_root._URL.substr(0, 5)).toLowerCase() != "file:") {
		if (this.indexOf("?") == -1) {
			return this += "?noCache=" + (new Date().getTime());
		} else {
			return this += "&noCache=" + (new Date().getTime());
		}
	} else {
		return this;
	}
};
//USAGE
//loadMovie("yourFile.swf".noCache());
//or
//loadVariablesNum("yourFile.txt".noCache(),1);
//or
//myXML.load("yourFile.xml".noCache()); 

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 17, 2003, 6:33pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/6 "2003-01-17T18:33:55Z")

</div>

the url should be [http://proto.layer51.com](http://proto.layer51.com) btw (I know thats not your doing andrthad) but technically that use is better because the date wont be repeated and theres a chance(however slim) random will be…plus it checks for further url concatenation.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 20, 2003, 5:14pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/7 "2003-10-20T17:14:43Z")

</div>

Hey andrthad,  
Did you get a chance to look over the code?  
Thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 20, 2003, 5:24pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/8 "2003-10-20T17:24:57Z")

</div>

No I didn’t. I just realized this morning I had forgotten. I will take care of you this evening. Sorry about that.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 22, 2003, 2:35pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/9 "2003-10-22T14:35:05Z")

</div>

Devante,

Sorry for the delay. See attached fla. You need to load to a target mc or a level. I chose to use a target mc.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 23, 2003, 6:30pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/10 "2003-10-23T18:30:09Z")

</div>

hey andrthad, thanks, but for some reason it is not working. I have no clue why. I even tried the file you sent me and I still found the swf file in my Temporary Internet Files. And also what do you mean you need to load to a target mc or a level?

You can check it as [http://www.geocities.com/ejbatu1/addcache.html](http://www.geocities.com/ejbatu1/addcache.html)

Thanks you

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 23, 2003, 7:36pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/11 "2003-10-23T19:36:20Z")

</div>

When you use the actionscript function loadMovie you need to load to a target movie clip. When you use the actionscript function loadMovieNum you need to load to a level. For instance:

[AS]

// **Load to a target mc**  
//TargetMC is an empty movie clip you create and drag to the  
//stage. Don’t forget to give it the instance name TargetMC.  
//The movie Test.swf will be loaded into the TargetMC.

TargetMC.loadMovie(“Test.swf”.noCache());

[/AS]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 23, 2003, 9:42pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/12 "2003-10-23T21:42:44Z")

</div>

okay, but how come I still find a .swf file in my Temporary Internet Files?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 23, 2003, 9:47pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/13 "2003-10-23T21:47:40Z")

</div>

There should still be a file there. You can’t clear a person’s cache on their machine. You can only make sure that the file in their cache is not used again. The way you control this is by adding the date and time to the “Test” string.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 24, 2003, 3:35pm UTC](https://forum.kirupa.com/t/script-needed-to-remove-swf-from-cache/11461/14 "2003-10-24T15:35:31Z")

</div>

I got you, but it would have been nice if there is a scripts would remove the swf file. Thanks for your help and patient
