Take the 2-minute tour ×

I am trying to allow offline browsing using ASIWebPageRequest and UIWebView. I attached the code I am using which seems to be working for other people who asked similar questions here on StakOverflow. The webpage is loaded perfectly, but nothing seems to be loading when the device isn't connected to the network. Can you please indicate what I am missing or whether I should manually load the cached data and if so, how?

[request setDelegate:nil];
[request cancel];

[self setRequest:[ASIWebPageRequest requestWithURL:url]];
[request setDelegate:self];
[request setDidFailSelector:@selector(webPageFetchFailed:)];
[request setDidFinishSelector:@selector(webPageFetchSucceeded:)];

[request setUrlReplacementMode:ASIReplaceExternalResourcesWithData];

[request setDownloadCache:[ASIDownloadCache sharedCache]];

request.cachePolicy = ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy;

[request setDownloadDestinationPath:[[ASIDownloadCache sharedCache] pathToStoreCachedResponseDataForRequest:request]];

[request startAsynchronous];
share|improve this question

1 Answer 1

To make the cache persistent you'll have to add

[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];

Without this line your example will only work if the internet connection breaks while the app is still running.

share|improve this answer

Your Answer


