The cache of webview can be divided into page cache and data cache.
Page cache refers to the HTML, JS, CSS, and other page or resource data when a webpage is loaded. These cache resources are generated by browser behavior. developers can only indirectly affect the cached data by configuring HTTP response headers.
Their indexes are stored in/data/package_name/databases. Their files are stored in/data/package_name/Cache/xxxwebviewcachexxx. The folder names are different in 2. x and 4. x, but both folder names contain webviewcache.
There are two types of data cache: appcache and Dom storage (Web storage ). They are produced by direct actions of page developers. All cached data is directly and completely controlled by developers.
Appcache allows us to buffer all the things in Web browsers, from pages, images to scripts, CSS, and so on. It is especially useful when it comes to CSS and JavaScript files applied to multiple pages of a website. The current size is usually 5 MB.
You must manually enable setappcacheenabled on Android and set the path (setappcachepath) and capacity (setappcachemaxsize)
In Android, WebKit uses a DB file to save appcache data (my_path/applicationcache. DB)
More detailed information can refer to here: http://www.itboat.net/thread-23674-1-1.html
If you need to store some simple data that can be solved using key/value pairs, Dom storage is a perfect solution. Based on different scopes, there are two types of storage: Session storage and local storage, which are used for session-level storage (when the page is closed, it disappears) and local storage (unless it is actively deleted, otherwise, the data will never expire ).
In Android, You can manually enable Dom storage (setdomstorageenabled) and set the storage path (setdatabasepath)
In Android, WebKit generates two files for Dom storage (my_path/localstorage/http_h5.m.taobao.com_0.localstorage and my_path/localstorage/databases. DB ).
In addition, when clearing the cache in Android, if you need to clear the local storage, it is not enough to delete the local storage file, and there is cache data in the memory. If you enter the page again, cache data in local storage also exists. Need to killProgramThe running process can be restarted.