ios - clearing a webviews cache for local files -


i've found similar posts, don't seem have effect i'm doing. i've got uiwebview i'm using display local content in bundle. i'm displaying docx file. user should ever @ document, , app tight on memory, want prevent uiwebview caching document. viable option clear cache when user leaves view. i'm totally ok having load scratch every time user enters view.

i load document so:

nsstring * path = [[nsbundle mainbundle] pathforresource:[nsstring stringwithformat:@"intro text"] oftype:@"docx"]; nsurl * url = [nsurl fileurlwithpath:path]; request = [nsurlrequest requestwithurl:url];  doc_view_rect = cgrectmake(5,105,self.view.frame.size.width,self.view.frame.size.height); doc_viewer = [[uiwebview alloc] initwithframe:doc_view_rect]; [doc_viewer loadrequest:request]; 

in attempts stop caching i've tried:

[[nsurlcache sharedurlcache] setmemorycapacity:0]; [[nsurlcache sharedurlcache] setdiskcapacity:0]; 

and:

nsurlcache *sharedcache = [[nsurlcache alloc] initwithmemorycapacity:0 diskcapacity:0 diskpath:nil]; [nsurlcache setsharedurlcache:sharedcache]; [sharedcache release]; sharedcache = nil; 

and:

if(request) {     [[nsurlcache sharedurlcache] removecachedresponseforrequest:request]; } [[nsurlcache sharedurlcache] removeallcachedresponses]; 

i tried setting web-views caching policy, seemed eat memory, when released webview, there still memory left behind. when re-entered , realloced didn't use same memory.

i don't think right direction though. these tagged ways stop webpages caching, seem have no effect local files. i'm not sure else go one. if knows how force cache clear, or prevent caching in first place appreciate help.

webkit maintains own caches in addition standard nsurlcache one. have no control on it.

realistically, have make sure code behaves under low memory warnings, , trust uiwebview same.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -