Jeff,

The test case is this:

Create an html page that requires a javascript file. Ensure that the javascript file has not been modified for at least an hour.
Load a page that includes a javascript file into a webview.
Now change the javascript file and reload the contents of the webview.
Any changes made to the javascript file will not be evident.

Now quit the app and restart. Load the contents of the html page. The changes should show up.
Alter the .js file again.
Reload the page and the changes should be reflected.

I can provide code that demonstrates this if desired.

Also, I have posted my issue on the webkit-dev mailing list.

Thanks,
-Adam

On Apr 10, 2009, at 11:27 AM, Jeff Johnson wrote:

If that's true, it sounds like a WebKit bug. Do you have a test case?

Also, just noticing the mailing list we're on. WebKit developers and others familiar with WebKit development tend to hang out on the webkitsdk-dev list, so you might have better luck with your question there.

-Jeff


On Apr 10, 2009, at 1:09 PM, Adam Thorsen wrote:

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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to