views:

78

answers:

3

Hi, Im doing some javascript code and im using firefox. i have a problem which is getting always the same result when im trying to print out an array. the array is calculated in the code through some algorithms. I realized that sometimes im getting new result when i clear private data in firfox by Tools --> Clear Private Data but i need to do it manually. the annoying thing as well that its not always working (sometimes i need to clear the data and do many refreshs for the page). Does anyone konw how can i clear this private data inside my javascript code so i might get ride of this problem. BTW: i disabled everythings in the privacy tab but still having the problem...

Thank you very much in advance

A: 

Forgive me if I misunderstood your question, but it sounds like you're trying to clear the browser's cache using javascript? That's not possible. However, you can prevent your page from being cached using the following meta tag at the top:

<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE" />

You can also do this:

<META HTTP-EQUIV="EXPIRES" CONTENT="Sat, 1 Jan 2000 00:00:01 GMT">

(note that the expiration is in the past)

I would do both.

steve
A: 

The only time you should need to Clear Private Data is when you have to clear the javascript files out of the cache. If you use the same javascript file and run the script over and over, if you are randomly filling in your array, or the array is different each time, then you should get different results.

You may want to use the Firebug extension to see what is going on in your javascript. That way you can look in the array as an input and as you go through your algorithms, and see if there is a problem.

If you show what you are using to fill your array and at least one algorithm then we can help you with the code.

As Steve mentioned, you can put in some code in your page to prevent the javascript from being cached, if you don't want to manually clear the cache. In production you will want it cached, I expect, to shorten the time to download.

James Black
you *definitely* want to use firebug to see what's going wrong. :D
CrazyJugglerDrummer
A: 

You can also setup your web server to not cache anything in the JavaScript directory, or pretty much any directory, which will force a refresh on content from that directory every time it's called.

Michael Mad