Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clearing cache doesn't work

11 views
Skip to first unread message

Daniel Kirsch

unread,
Mar 11, 2010, 7:25:13 AM3/11/10
to
In my XULRunner application I have an iframe containing a html document.
When changing images referenced in the html document I still get the old
(cached) images.

I clear the cache using this method:

var classID = Components.classes["@mozilla.org/network/cache-service;1"];
var cacheService =
classID.getService(Components.interfaces.nsICacheService);
var c = Components.interfaces.nsICache;
cacheService.evictEntries(c.STORE_ON_DISK);

I tried c.STORE_ANYWHERE too but I still get the cached images. This
worked for older version of XULRunner and it works in a chrome window
using XUL but not in the html window.

Any idea what could be the cause? Will the iframe cache not be cleared
anymore?

Thanks
Daniel

Neil

unread,
Mar 11, 2010, 7:48:21 AM3/11/10
to
Daniel Kirsch wrote:

> In my XULRunner application I have an iframe containing a html
> document. When changing images referenced in the html document I still
> get the old (cached) images.
>
> I clear the cache using this method:
>
> var classID = Components.classes["@mozilla.org/network/cache-service;1"];
> var cacheService =
> classID.getService(Components.interfaces.nsICacheService);
> var c = Components.interfaces.nsICache;
> cacheService.evictEntries(c.STORE_ON_DISK);
>
> I tried c.STORE_ANYWHERE too but I still get the cached images.

The image cache no longer uses the cache service, instead it has its own
cache. Sorry, but I don't know whether it's possible to clear the image
cache, maybe someone else can help.

--
Warning: May contain traces of nuts.

Axel Hecht

unread,
Mar 11, 2010, 8:11:24 AM3/11/10
to

"@mozilla.org/image/cache;1" implements imgICache.

Axel

Daniel Kirsch

unread,
Mar 11, 2010, 9:07:46 AM3/11/10
to

You guys made my day! I struggled for hours now and with your help the
solution took 5 minutes. Here is my code which does the trick:

var classID = Components.classes["@mozilla.org/image/cache;1"];
var cacheService = classID.getService(Components.interfaces.imgICache);
cacheService.clearCache(false);

I've found the helpful source at
http://www.oxymoronical.com/experiments/xpcomref/applications/Firefox/3.6a1pre/interfaces/imgICache

Thanks a lot for the fast answer!
Daniel

David_Frahm

unread,
Mar 12, 2010, 9:55:57 AM3/12/10
to
> I've found the helpful source athttp://www.oxymoronical.com/experiments/xpcomref/applications/Firefox...

>
> Thanks a lot for the fast answer!
> Daniel

So to really clear *all* the cache, you would need to use both? Are
there other classes for other content types?

0 new messages