Android webview cache Analysis

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.