[webkit-dev] WebKit caching

Darin Adler darin at apple.com
Fri Apr 10 15:01:57 PDT 2009

There are three different caches involved in WebKit on Mac OS X.

     A) The resource cache in the NSURL networking layer, which caches  
both in memory and on disk.
     B) The resource cache inside WebCore, which caches in memory.
     C) The page cache in WebCore, a higher level cache which only  
affects "go back" and "go forward" commands.

> 1.  Overriding the NSURLCache cachedResponseForRequest and  
> cachedResponse forRequest methods

To turn off cache (A) you can call:

     [[NSURLCache sharedURLCache] setMemoryCapacity:0];
     [[NSURLCache sharedURLCache] setDiskCapacity:0];

>    WebPreferences *prefs = [webView preferences];
>    [prefs setUsesPageCache:NO];

The code above turns off cache (C).

One way to turn off cache (B) is to do this:

     [prefs setCacheModel:WebCacheModelDocumentViewer]

I suggest giving that a try.

     -- Darin

More information about the webkit-dev mailing list