Sign in to follow this  
Followers 0
7121

clearing cache with _FFCmd

3 posts in this topic

Hey guys, I know this is probably an easy task but I don't know how to clear the cache on the MozRepl, or either that I really don't know my javascript anyway.

The cache I wanted to clear is the Memory cache, i searched around and i came to this

function clearcachebutton_clearCache()

{

var cacheService = getCacheService();

var alertService = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService);

var loc = new localizedStrings();

try

{

cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);

cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);

notify(loc.popupTitle, loc.successMessage);

}

catch(exception)

{

notify("Exception", exception);

}

//

// return a reference to the cache service

//

function getCacheService()

{

var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];

var service = cacheClass.getService(Components.interfaces.nsICacheService);

return service;

}

// Notify user

function notify(title, body)

{

alertService.showAlertNotification("chrome://clearcache/skin/logo_32.png", title, body, false, "", null);

}

}

I tried sending the commands with this:

_FFCmd("cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);")

and

_FFCmd("cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);")

So far I'm only recieving errors back. Can anyone help me? I could get an addon but then i would have to study the javascript in the addon itself wouldn't I?

Share this post


Link to post
Share on other sites



You have to define "cacheService" before you can use it. Try this:

_FFCmd('var cacheService = Components.classes["@mozilla.org/network/cache-service;1"].getService(Components.interfaces.nsICacheService);')

Share this post


Link to post
Share on other sites

Thank you DAN, i beleive you are right, i took a look at the patterning and it appears you have to do some combining and I didn't know how to combine the functions haha so I believe this will work. I'm going to try it now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0