当前位置:网站首页>Android HTML5 page load cache optimization
Android HTML5 page load cache optimization
2022-06-12 02:13:00 【Five wood】
Program ape everyday
Hard pressed programmers should be nice to themselves !
LZCache Use
https://github.com/wugemu/WebTest
Application In the initialization The code is as follows :
// initialization
List<String> cacheList=new ArrayList<String>();// Cached resources
cacheList.add(".js");
cacheList.add(".css");
cacheList.add(".ico");
cacheList.add(".png");// picture
cacheList.add(".jpg");
cacheList.add(".gif");
cacheList.add(".action?");// Page request
CacheUtil.initOnlyCache(512 * 1024 * 1024, cacheList);// Maximum cache 512MB
notes : Discuss What data is cached
initOnlyCache(long cacheMax,List<String> cacheList)
cacheMax Maximum cache capacity , Only right cacheList Cache files in ( The string contains )
initAllCache(long cacheMax,List<String> noCacheList)
cacheMax Maximum cache capacity , Only right noCacheList Files in are not cached ( The string contains )
1 First load optimization
CacheUtil.loadUrl(WebView webview, Content content, String url, Map<String ,String> headpara);
This method realizes webview Loading and html Content requests are asynchronous ,html The content will be displayed immediately after it is obtained , There is no need to wait for the resource to load , And cache it to the local to synchronize updates , Using this method, offline mode can be realized ( The cache file is completely ).
notes : html5 When there is a request in , Cross domain settings are required ;
2 Cache mechanism optimization
webView.setWebViewClien(new WebViewClientCache());
The sample code is as follows :
webView.setWebViewClient(new WebViewClientCache(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
});
边栏推荐
- Glfwpollevents() program crash
- Force deduction solution summary 868- binary spacing
- ACL 2022 | 预训练语言模型和图文模型的强强联合
- RPA introduction
- 力扣解法汇总675-为高尔夫比赛砍树
- [no title] 2022 coal mine safety inspection test questions and online simulation test
- A mystery of the end of vagrant up
- UE4\UE5触摸屏touch事件:单指、双指
- 力扣解法汇总497-非重叠矩形中的随机点
- Force deduction solution summary 732- my schedule III
猜你喜欢

The release of star ring kundb 2.2 provides a new choice for business systems with high concurrent transactions and queries

阿里云oss文件上传系统

Layered architecture of DDD

DDD的分层架构

RPA introduction

MySQL表常用操作思维导图

Graphic data analysis | data cleaning and pretreatment

ACL 2022 | 预训练语言模型和图文模型的强强联合

matplotlib. pyplot. Bar chart (II)

消防栓监测系统毕业设计---论文(附加最全面的从硬件电路设计->驱动程序设计->阿里云物联网搭建->安卓APP设计)
随机推荐
leetcodeSQL:612. Nearest distance on plane
力扣解法汇总面试题 17.11-单词距离
RPA introduction
力扣解法汇总699-掉落的方块
A mystery of the end of vagrant up
Proxy and reflection (II)
Force deduction solution summary interview question 17.11- word distance
力扣解法汇总944-删列造序
力扣解法汇总868-二进制间距
Why do we use Google search ads?
力扣解法汇总358-迷你语法分析器
Force deduction solution summary 1037- effective boomerang
力扣解法汇总467-环绕字符串中唯一的子字符串
力扣解法汇总449-序列化和反序列化二叉搜索树
力扣解法汇总386-字典序排数
Swiftyjson analyse les fichiers json locaux
matplotlib. pyplot. Bar chart (II)
Graphical data analysis | business analysis and data mining
The most comprehensive redis transaction control in 2022 (with illustration)
Knowledge points of mall development