UIWebView ignores disk cache?

In my hybrid application, I name a web resource, for example main.css?{timestamp-file-was-modified} , and give them a cache header with a maximum age of one year so that clients keep it more or less forever.

Something similar to my iOS application, however, that the UIWebView evaluates the cache header during the life of the application, i.e. when I load a new page that also includes main.css?{same-timestamp} , it won’t even try to repeat the check because it knows that it has the desired file in the cache. BUT , when you restart the application (after disconnecting or disconnecting the device), UIWebView retrieves all resources again, ignoring the cache. I ran it through Charles Proxy to make sure this is so.

I looked into SQlite cache.db, and I see that main.css?{same-timestamp} is there, but still UIWebView will not load it from the cache, as a result of which the initial loading of the page will be much slower than it can be.

I tried this on an iPhone with iOS 8.4 and an iPad with iOS 8.2. The same result.

Any ideas?

+5
source share
1 answer

If you really like managing the cache, you can register your custom subclass NSURLProtocol in the deletion, and then with the help of - (void)startLoading you can load anything from the local storage.

0
source

All Articles