Dark Launch

Clear Firefox Cache Hotkey/Shortcut using Keyconfig

UPDATE: https://addons.mozilla.org/en-US/firefox/addon/5364/


To clear Firefox's cache using a simple hotkey, do the following:

1. Install Keyconfig.
2. Add a new key named Clear Cache.
3. Add the following code:

var cacheService = Components.classes["@mozilla.org/network/cache-service;1"].getService(Components.interfaces.nsICacheService);
var alertsService = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService);
    alertsService.showAlertNotification(null, "Success", "Cache cleared!", false, "", null);
    alertsService.showAlertNotification(null, "Exception", exception, false, "", null);

4. Set your preferred hotkey.
5. Open a new window for the hotkey to work. Press the hotkey you set and a notification in the corner will appear.

Go to about:cache in Firefox to see cache usage before and after clearing cache.

Other Storage Policy:
STORE_ANYWHERE - cache stored in any device
STORE_IN_MEMORY - cache entry in non-persistent storage (RAM)
STORE_ON_DISK - cache entry in persistent storage (HDD)
STORE_ON_DISK_AS_DISK - cache entry in persistent storage in a specific file