WebKit Caching
WebKit Caching
- Subject: WebKit Caching
- From: Adam Thorsen <email@hidden>
- Date: Fri, 10 Apr 2009 09:27:15 -0700
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