I have an activity with a WebView and want to cache content. By default, it does not appear to be using the cache.
Android's WebSettings has several different cache-related constants.
When I set the cache mode to 'LOAD_CACHE_ELSE_NETWORK', it appears to use the cache. However, I don't want to use expired cache content.
This leaves me with using:
But the documentation does not elaborate on what "normal" and "default" mean.
How do these two modes differ?
When a WebView is first created, it obtains a set of default settings. These default settings will be returned from any getter call. A WebSettings object obtained from WebView#getSettings() is tied to the life of the WebView.
Configuring WebView Settings with WebSettings getSettings() object if a WebView is already destroyed. You can retrieve WebSettings with WebView. getSettings() API.
I agree, one would expect that NORMAL_MODE is the default mode, but clearly this is two different values.
I think answer to question 2. (LOAD_NORMAL) is answered in the documentation for WebSettings.setCacheMode(int mode)
For a normal page load, the cache is checked and content is re-validated as needed. When navigating back, content is not revalidated, instead the content is just pulled from the cache. This function allows the client to override this behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With