Home » Android » caching – Why doesn't android Webview check for cache by default?

caching – Why doesn't android Webview check for cache by default?

Posted by: admin June 15, 2020 Leave a comment


I have a webview using application caching. I launched the app with a connection to the network in order to load/cache the page. Now, after turning the wifi (and 3g – no network connection) off, and launch the app, I get shown the “android could not load the page” page. Oddly, if I then reload the webview, it loads up the page from cache. Why doesn’t it load this page from the cache if it can’t connect to the network?

I’m using HTML5 Application Cache with cache.manifest. Here’s my webview code to enable this:


I tried adding in:


but it didn’t help.

How to&Answers:

Check to see if the URL you’re requesting isn’t a redirect. If it is, the cache will be pointing to that redirect as well, and the WebView won’t read the resulting redirect from the cache.

It took me some time to figure out that this was what was happening in my case.