PDA

View Full Version : Clear Cache Script



Jim Weinberg
01-29-2006, 01:52 PM
I decided to post this as a new thread.

I'm reloading a page with an animated gif. When NS reloads the page it takes the graphic from cache -- no animation. Is there a script to clear the NS cache? The problem doesn't seem to exist in IE.

jscheuer1
01-29-2006, 05:27 PM
Are you sure that is what is happening? An animated .gif is an image, and if cached, will still be animated whether retrieved from the cache or from the web. If the problem is that regardless of what I've just stated, it still acts like what you are saying and there is no other cause at work, this may help (requires a transparent .gif):


<img src="transparent.gif" onload="if(this.src.indexOf('my_animated.gif')==-1)this.src='my_animated.gif'">

.

How are you reloading the page?

Jim Weinberg
01-30-2006, 01:39 PM
Hi John.

The graphic is a transparent gif. It works fine in IE, but not in NS. If I manually clear the cache in NS before the reload, then it works. But only the next time. Then nothing.

The code's not on a server -- yet. So I can't let you look at it. But here's the "reload" code:

<script type="text/javascript">
<!-- Begin
function reFresh() {
window.location="Logo.html"
}
/* Set the number below to the amount of delay, in milliseconds,
you want between page reloads: 1 minute = 60000 milliseconds. */
window.setInterval("Doit()",15000);
// End -->
</script>

jscheuer1
01-30-2006, 02:05 PM
<script type="text/javascript">
<!-- Begin
function reFresh() {
window.location="Logo.html"
}
/* Set the number below to the amount of delay, in milliseconds,
you want between page reloads: 1 minute = 60000 milliseconds. */
window.setInterval("Doit()",15000);
// End -->
</script>

That won't do anything as Doit() is not defined.

Jim Weinberg
01-30-2006, 06:44 PM
Sorry. Didn't drag the cursor down far enough.

<script>

function Doit(){
parent.Logo.location='Logo.html';
</script>

Logo.html contains the animated gif.

Twey
01-30-2006, 07:53 PM
You haven't closed the function block.


<img src="transparent.gif" onload="if(this.src.indexOf('my_animated.gif')==-1)this.src='my_animated.gif'">Urgh, nasty. I do not recommend this, due to the fact that non-JS browsers won't be able to see the image.

jscheuer1
01-30-2006, 08:46 PM
You haven't closed the function block.
Urgh, nasty. I do not recommend this, due to the fact that non-JS browsers won't be able to see the image.

I didn't open one either. It works, trust me. Good point on non-JS browsers though. It was just something to try if there truly were a problem with the cache, which I don't think there is. After going over most (if not all) of the OP's posts though, I think it is just that his code is slipshod.

Jim Weinberg
01-30-2006, 09:01 PM
Twey. Thanks for your input. I don't want to take a chance on it not working for non-js browsers.

BTW, its nice to see that not everyone has to make negative comments in order to show how "knowlegable" they are. I'm only 12 and am just starting out with JS. I was about to give up asking questions on this forum until I read your reply.

Thanks again.

jscheuer1
01-30-2006, 09:35 PM
BTW, its nice to see that not everyone has to make negative comments in order to show how "knowlegable" they are. I'm only 12 and am just starting out with JS. I was about to give up asking questions on this forum until I read your (Twey's) reply.

Thanks again.

I knew we were keeping Twey around for a reason. :) Jim, don't feel bad. There is plenty I do not know. It just gets frustrating when the code I need to see in order to help is not there. Also, it can reach a point where I don't know if what someone is posting is what they have or just a poor copy of it. In any case, regardless of my tone or how you feel about it, code must be written properly (for the most part) to work. There are exceptions in certain browsers and quirks of other browsers that should be respected if you want your code to work in them. But, as I say, don't give up. At least you are trying.

Twey
01-31-2006, 04:31 PM
You didn't close the function block.I didn't open one either.I was referring to the OP's DoIt() function.

I knew we were keeping Twey around for a reason. :)It's evidently my amazing people skills. Maybe I should become a banker. ;)

Jim Weinberg
02-01-2006, 12:09 PM
Hey guys.

This is all well and good, but I still don't have an answer to my question: is there a way to clear the NS cache from a scipt?:confused:

Twey
02-01-2006, 03:56 PM
No.
At least, I hope not.
If there is, it's a security flaw.

Jim Weinberg
02-01-2006, 07:04 PM
Twey.

Thanks. I was afraid that would be the answer. Guess I'll have to stick with IE. It doesn't have the problem.

Again, many thanks for your help.