0

My OSX app is attempting to load a web page inside a webview. I require caching the web page for the faster laoding of the page between successive launches of the app.

All the resource files(js/css/images) linked to the page is cached except one js file of 3MB size. I verified this in the cache.db file and no entry related to this particular file is present in the related table.

I have attempted many things, including

  • increasing the cache memory capacity
  • increasing timeout time for the request
  • changing parameters for cache policy

The workaround identified is to explicitly request the js file and forcefully store it in the cache.

[[NSURLCache sharedURLCache] storeCachedResponse:cachedURLResponse forRequest:request];

This will properly cache the file and on subsequent launches, there is only minimal network activity. This obviously is not a solution.

I'm not sure whether the file size matters, as i didn't find any reference related to size in NSURLCache documentation. One other observation is that the 'didFinishLoadForFrame' delegate is called before the linked resources are loaded.

Appreciate any help in this regard,

Thanks,

Jimesh

J. Thomas
  • 1
  • 2

1 Answers1

0

Yes, file size matters. The standard behavior of the cache is to not store anything that's larger than five or ten percent of the size of the cache. Increase the size of the cache to be at least two orders of magnitude bigger than what you're caching, and it will probably "just work".

If that isn't working, it probably indicates that the cache policy being sent back by the server for that one file disallows caching.

And if that isn't the problem, please update your question with the URL of the file that isn't being cached, and a code snippet showing how you configured the cache size.

dgatwood
  • 10,129
  • 1
  • 28
  • 49