[webkit-dev] WebKit caching

Darin Adler darin at apple.com
Sun Apr 12 11:25:42 PDT 2009


The answer to both questions is yes. You could file a bug report for  
this and since the buildable source code for WebKit is available at  
webkit.org you could do more research about why your test application  
gets different behavior than Safari with caches disabled.

     -- Darin

Sent from my iPhone

On Apr 12, 2009, at 9:15 AM, Adam Thorsen <adam.thorsen at gmail.com>  
wrote:

> I removed the willSendRequest method and set the cache model and  
> disk capacity ( without setting the memory capacity ) with the same  
> results.  Is this enough information to file a bug report with or is  
> there some more work I could do to track this down?
>
> Thanks again,
> -Adam
>
>
> On Apr 11, 2009, at 11:51 PM, Darin Adler wrote:
>
>> 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 app 
>> lication.
>>
>>>       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 cac 
>> he policy (and you should not need to do this, see my original mes 
>> sage), 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