[webkit-dev] WebKit caching
Darin Adler
darin at apple.com
Sat Apr 11 23:51:43 PDT 2009
On Apr 11, 2009, at 6:54 PM, Adam Thorsen wrote:
> I also noticed recently that there is a "Disable Caches" option
> under the Develop menu on Safari. I tested it using the same
> procedure and it indeed did not cache the javascript, so I know this
> is possible one way or another.
It’s true, Disable Caches does this.
In fact, I read over the implementation of that menu item before
answering your original question. All that Safari does when that menu
item is selected is:
[[WebPreferences standardPreferences]
setCacheModel:WebCacheModelDocumentViewer];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
I’m not sure why that works better in Safari than in your test
application.
> NSURL * url = [aRequest URL];
> NSURLRequest * cachelessRequest = [NSURLRequest
> requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData
> timeoutInterval:100];
> return cachelessRequest;
This code in your willSendRequest delegate method may be causing a
problem. It discards the request and creates a new one, taking only
the URL from the original request. That’s a problem because there are
other important fields in the request, such as the HTTP method, HTTP
body, and HTTP header fields. If you want to change the cache policy
(and you should not need to do this, see my original message), you
would need code more like this:
if ([request cachePolicy] == NSURLRequestReloadIgnoringCacheData)
return request;
NSURLRequest *cachelessRequest = [aRequest mutableCopy];
[cachelessRequest
setCachePolicy:NSURLRequestReloadIgnoringCacheData];
return cachelessRequest;
Hope that helps.
-- Darin
More information about the webkit-dev
mailing list