2 * (C) Copyright 2008 Nicholas A. Zigarovich
4 * Use, modification, and distribution are subject to the terms specified in the
8 var CACHE_MEMORY
= Ci
.nsICache
.STORE_IN_MEMORY
;
9 var CACHE_DISK
= Ci
.nsICache
.STORE_ON_DISK
;
10 var CACHE_OFFLINE
= Ci
.nsICache
.STORE_OFFLINE
;
11 var CACHE_ALL
= Ci
.nsICache
.STORE_ANYWHERE
;
13 function cache_clear(cache_type
) {
14 let cs
= Cc
["@mozilla.org/network/cache-service;1"]
15 .getService(Ci
.nsICacheService
);
16 cs
.evictEntries(cache_type
);
17 if (cache_type
== CACHE_DISK
)
18 cs
.evictEntries(Ci
.nsICache
.STORE_ON_DISK_IN_FILE
);
21 function cache_disable(cache_type
) {
22 if (cache_type
== CACHE_MEMORY
)
23 session_pref("browser.cache.memory.enable", false);
24 else if (cache_type
== CACHE_DISK
)
25 session_pref("browser.cache.disk.enable", false);
26 else if (cache_type
== CACHE_OFFLINE
)
27 session_pref("browser.cache.offline.enable", false);
28 else if (cache_type
== CACHE_ALL
) {
29 cache_disable(CACHE_MEMORY
);
30 cache_disable(CACHE_DISK
);
31 cache_disable(CACHE_OFFLINE
);
34 throw new Error("Invalid cache type");
37 function cache_enable(cache_type
) {
38 if (cache_type
== CACHE_MEMORY
)
39 session_pref("browser.cache.memory.enable", true);
40 else if (cache_type
== CACHE_DISK
)
41 session_pref("browser.cache.disk.enable", true);
42 else if (cache_type
== CACHE_OFFLINE
)
43 session_pref("browser.cache.offline.enable", true);
44 else if (cache_type
== CACHE_ALL
) {
45 cache_enable(CACHE_MEMORY
);
46 cache_enable(CACHE_DISK
);
47 cache_enable(CACHE_OFFLINE
);
50 throw new Error("Invalid cache type");