[webkit-help] clearing the cache

Adam Roben aroben at apple.com
Tue Sep 13 10:49:48 PDT 2011

On Sep 12, 2011, at 5:37 PM, aaron reed wrote:

> I'm embedding WebKit on my own Windows c# control and I'd like to clear the cache for WebKit.  I tried doing this:
> HRESULT WKWrapper::emptyCache()
> {
>     IWebCache *webCache = NULL;
>     HRESULT rv = WebKitCreateInstance(CLSID_WebCache, 0, IID_IWebCache, (void**)&webCache);
>     if (FAILED(rv)) {
>         return rv;
>     }
>     if (!webCache) {
>         return E_FAIL;
>     }
>     rv = webCache->empty();
>     webCache->Release();
>     return rv;
> }
> This doesn't seem to clear the cache, though.  I still have to reload the page to see changes to the web page.

I'm not sure what you mean here. Are you expecting IWebCache::empty to cause all pages to reload immediately so that the new resources will be fetched?

> Navigating forward or backward won't show the changes.  But emptying the cache in Safari and then navigating forward or backward
> will show the changes.
> Am I missing something?  Is there some way to get the WebCache object from WebKit by querying it?  Looking at the code
> that didn't seem necessary (since everything WebCache::empty() calls is static).

IWebCache doesn't modify any cache(s) that the network layer maintains. So you probably need to figure out what network layer your version of WebKit is using and do something to empty its cache(s).


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20110913/ba5db8ab/attachment.html>

More information about the webkit-help mailing list