title: Is it possible to cache resources loaded in an iPhone UIWebView?
body: <p>I have a simple app loading a site optimized for the iPhone in a <code>UIWebView</code>.</p>
  
  <p>Problem is, caching does not seem to work:</p>
  
  <pre><code>[webView loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: url]
                                         cachePolicy: NSURLRequestUseProtocolCachePolicy
                                     timeoutInterval: 60.0]];
  </code></pre>
  
  <p>Any things referenced in this remote page (css, images, external javascript files) never get cached (the requests never send a If-Modified-Since header or anything else in the way of cache control.)</p>
  
  <p>Is it possible?  It seems with a regular Cocoa WebView there a delegate methods that get called for each resource request and post load (<code>-didFinishLoadingFromDataSource:</code>) which you could use to roll your own caching.. but that does not seem applicable here.</p>
  
  <p>My entire page (page and its referenced resources) is around 89K compressed.. which is slow over 3G in some spots and even worse over EDGE.  Incoming requests are at least indicating that it accepts compression (<code>accept-encoding=gzip, deflate</code>), so that's good I suppose.</p>
  
  <p>I read <a href="http://yuiblog.com/blog/2008/02/06/iphone-cacheability/" rel="nofollow noreferrer">this yui study</a>, which seems to indicate that the iPhone will cache 25k per item. The only thing referenced that is over 25k uncompressed is jquery (packed but uncompressed - it is 30k). Everything else should be cacheable. No request for anything referenced in the page fetched is triggering a 304 on the server side.</p>
  
  <p>That yui study was from almost a year ago, and I am guessing with mobile safari only. </p>
  
  <p>This is using a <code>UIWebView</code> in a native iPhone app.</p>