the WebView cache can be divided into page caches and data caches.
Page caching refers to HTML, JS, CSS, and other pages or resource data when a page is loaded. These cache resources are generated by the browser's behavior, and developers can only influence the cached data indirectly by configuring the HTTP response header to affect the browser's behavior.
Then the relevant cache-to-address directory is:
The requested URL record is saved in Webviewcache.db, and the content of the URL is saved under the Webviewcache folder.
cache composition
/data/data/package_name/cache/
Cache mode (5 types)
Load_cache_only: Do not use the network, only read local cache data
Load_default: Decide whether to fetch data from the network according to Cache-control.
Deprecated in Load_cache_normal:api level 17, starting from API level 11 with Load_default mode
Load_no_cache: Do not use caching, only get data from the network.
Load_cache_else_network, the data in the cache is used whenever there is a local, regardless of whether it expires, or No-cache.
such as: www.taobao.com Cache-control for No-cache, in the mode Load_default, regardless of the data will be taken from the network, if there is no network, there will be error page; in Load_cache_else_ In network mode, the cache is used whenever there is a local cache, regardless of whether there are networks. The local cache is not available from the network.
The Cache-control for www.360.com.cn is max-age=60, and local cache data is used in both modes.
Summary: According to the above two modes, the proposed cache strategy is to determine if there is a network, if so, use Load_default, no network, use Load_cache_else_network.
Android WebView Cache