ios6 - loading cached webpage in UIWebView in ios -


i've task increasing speed of webpage loading in uiwebview. i'm moving cache concept. here i'm using asiwebpagerequest cache content of webpage. doing well.but when load cached webpage, hyperlinks not working(not linking live url)?

and one. if webpage cached means,its loads cache otherwise loads live url. how can fix it?

here code:

- (void)fetchurl:(nsurl *)url {      [self setrequestsinprogress:[nsmutablearray array]];      [request setdelegate:nil];     [request cancel];     [self setrequest:[asiwebpagerequest requestwithurl:url]];      [request setdidfailselector:@selector(webpagefetchfailed:)];     [request setdidfinishselector:@selector(webpagefetchsucceeded:)];     [request setdelegate:self];     [request setdownloadprogressdelegate:self];     [request seturlreplacementmode:asireplaceexternalresourceswithdata];        [request setdownloadcache:[asidownloadcache sharedcache]];     [request setcachepolicy:asionlyloadifnotcachedcachepolicy];      // efficient way set download path asiwebpagerequest, writes cache directly     [request setdownloaddestinationpath:[[asidownloadcache sharedcache] pathtostorecachedresponsedataforrequest:request]];      [[asidownloadcache sharedcache] setshouldrespectcachecontrolheaders:no];     [request startasynchronous]; }   - (void)webpagefetchfailed:(asihttprequest *)therequest {     nslog(@"fetch error = %@",[therequest error]); }  - (void)webpagefetchsucceeded:(asihttprequest *)therequest {     nsurl *baseurl;     if ([request isfinished] ) {           baseurl = [nsurl fileurlwithpath:[request downloaddestinationpath]];           //        // if we're using asireplaceexternalresourceswithlocalurls, must set baseurl point our locally cached file     } else {         baseurl = [request url];     }      if ([therequest downloaddestinationpath]) {          nsstring *response = [nsstring stringwithcontentsoffile:[therequest downloaddestinationpath] encoding:[therequest responseencoding] error:nil];          [webview loadhtmlstring:response baseurl:baseurl];       } else {          [webview loadhtmlstring:[therequest responsestring] baseurl:baseurl];     }   } 

change line

[[asidownloadcache sharedcache] setshouldrespectcachecontrolheaders:no]; 

to

[[asidownloadcache sharedcache] setshouldrespectcachecontrolheaders:yes]; 

it work


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -