Re: WebKit Caching
Re: WebKit Caching
- Subject: Re: WebKit Caching
- From: Adam Thorsen <email@hidden>
- Date: Fri, 10 Apr 2009 11:09:15 -0700
Jeff,
Thanks for the response. These techniques do not appear to affect how
WebKit caches javascript resources.
This is what I tried:
WebPreferences *prefs = [webView preferences];
[prefs setUsesPageCache:NO];
and
WebPreferences *prefs = [webView preferences];
[prefs setPrivateBrowsingEnabled:YES];
Thanks,
-Adam
On Apr 10, 2009, at 9:58 AM, Jeff Johnson wrote:
Adam,
I think that -[WebPreferences setUsesPageCache:] should work. -
[WebPreferences setPrivateBrowsingEnabled:] will also have this
effect, though it may be more than you want.
-Jeff
On Apr 10, 2009, at 11:27 AM, Adam Thorsen wrote:
I would like to prevent a WebKit WebView from caching certain
content. I've attempted to prevent this using several approaches,
including:
1. Overriding the NSURLCache cachedResponseForRequest and
cachedResponse forRequest methods
2. Handling -(NSURLRequest *)webView:(WebView *)sender resource:
(id) willSendRequest:(NSURLRequest *) redirectResponse:
(NSURLResponse *) fromDataSource:(WebDataSource *)dataSource
a) tried setting the cache policy to
NSURLRequestReloadIgnoringCacheData, among other settings
b) tried appending a random string onto the end of the
resource url before passing it along (i.e. something like http://blah.com/file.js?23234234234)
3. Clearing the cache by setting the shared url cache (via
NSURLCache ) and calling removeAllCachedResponses before each page
load.
None of these approaches have any effect on what the webview
instance decides to cache. Based on its behavior, I believe that
on initial page load it checks the last-modified value in each
response header and caches resources in memory that have not been
modified within a certain period of time. Recently modified files
(within the past few minutes) are not cached.
My ultimate goal is simply to prevent the webview from caching,
and I am open to any suggestions on how to do that. However, based
on my above hypothesis about how WebKit handles caching internally,
I believe that if I could rewrite the response headers such that
last-modified is always a recent value, I could prevent WebKit from
caching.
Currently I can view the response header by implementing:
- (void)webView:(WebView *)sender resource:(id)identifier
didReceiveResponse:(NSURLResponse *)response fromDataSource:
(WebDataSource *)dataSource
and calling allHeaderFields on the response. However, there
appears to be no way to modify the response before sending it on to
the webview for display. Are there any suggestions on how to do
this?
Thanks,
-Adam
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden