Webview has two types of cache: webpage data cache (storing opened pages and resources) and H5 cache (appcache ).
I. webpage Cache
1. cache Composition
/Data/package_name/Cache/
/Data/package_name/database/webview. DB
/Data/package_name/database/webviewcache. DB
2. cache Mode
The following two modes are hard to understand:
Load_default: determines whether to retrieve data from the Network Based on Cache-control.
Load_cache_else_network: cache data is used as long as it exists locally, whether it expires or not, or no-cache.
For example, m.taobao.com's cache-control is no-Cache. In the load_default mode, data is retrieved from the network in any case. If there is no network, an error page is displayed; in load_cache_else_network mode, cache is used no matter whether there is a network or not, as long as there is a local cache. It is obtained from the network only when there is no cache locally.
M.sina.com.cn's cache-control is Max-age = 60, and local cache data is used in both modes.
Conclusion: Based on the above two modes, the cache policy is recommended to determine whether a network exists. If yes, load_default is used. If no network exists, load_cache_else_network is used.
3. Clear Cache
Sort AchE (Boolean ).
Cachemanager. Clear. In a later version, you must call the hidden API.
4. Control the size
No system API support.
Optional: regularly calculates the cache size and deletes the cache in chronological order.
Ii. H5 Cache
1. cache Composition
Based on the path provided by setappcachepath (string appcachepath), H5 uses the cache file generated during the cache process.
2. cache Mode
If no mode is selected, use setappcacheenabled (Boolean flag) to set whether to enable it. Disabled by default, that is, H5 cache cannot be used.
3. Clear Cache
Find the cache path set by calling setappcachepath (string appcachepath) and delete all the files under it.
4. Control the size
Use setappcachemaxsize (long appcachemaxsize) to set the maximum cache capacity. The default value is Max integer.
In addition, you may overwrite webchromeclient. onreachedmaxappcachesize (long requiredstorage, long quota, webstorage. quotaupdater) to set the policy when the cache exceeds the previously set maximum capacity.
Iii. Reference URL
The following address provides some information about H5 cache. For example, each application only calls websettings. setappcachepath (), websettings. setappcachemaxsize (), and so on. You need to read and experiment carefully.
Http://code.google.com/p/android/issues/detail? Id = 24180