当前位置:网站首页>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);
}
});
边栏推荐
- 力扣解法汇总-剑指 Offer II 114. 外星文字典
- Don't miss it! Five large data visualization screens that HR must collect
- Layered architecture of DDD
- Implementation scheme of iteration and combination pattern for general tree structure
- Swiftyjson parsing local JSON files
- Linux(CentOS6)安装MySQL5.5版本数据库
- 没有文笔,大家多多包涵
- Master of a famous school has been working hard for 5 years. AI has no paper. How can the tutor free range?
- 力扣解法汇总675-为高尔夫比赛砍树
- Knowledge points of mall development
猜你喜欢

Summary of concrete (ground + wall) + Mountain crack data set (classification and target detection)
![[adjustment] notice on the opening of the 2022 pre adjustment system for postgraduate enrollment of Shanghai Second University of Technology](/img/16/2f9a235995cdd54ac9b85a68a7afcb.jpg)
[adjustment] notice on the opening of the 2022 pre adjustment system for postgraduate enrollment of Shanghai Second University of Technology

Graphical data analysis | data analysis tool map

Almost all schools will ask for the second round exam! Come in and recite the answer!

How to stop anti-virus software from blocking a web page? Take gdata as an example

超图倾斜数据合并根节点后转3dtiles

BaseDexClassLoader那些事

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

混泥土(地面+墙面)+ 山体裂缝数据集汇总(分类及目标检测)

Ozzanation - système d'action basé sur sse
随机推荐
Force deduction solution summary 449 serialization and deserialization binary search tree
Force deduction solution summary - Sword finger offer II 114 Alien dictionary
[adjustment] notice on the opening of the 2022 pre adjustment system for postgraduate enrollment of Shanghai Second University of Technology
Alicloud OSS file upload system
力扣解法汇总953-验证外星语词典
消防栓监测系统毕业设计---论文(附加最全面的从硬件电路设计->驱动程序设计->阿里云物联网搭建->安卓APP设计)
通用树形结构的迭代与组合模式实现方案
力扣解法汇总1728-猫和老鼠 II
How to improve the advertising rating of advertising, that is, the quality score?
leetcode:6. Zigzag transformation
adb命令 利用jks文件给apk签名
Proxy and reflection (II)
Graphic data analysis | business cognition and data exploration
Force deduction solution summary 942- increase / decrease string matching
力扣编程题-解法汇总
力扣解法汇总358-迷你语法分析器
2022 western style pastry (technician) recurrent training question bank and online simulated examination
Force deduction solution summary 699- dropped blocks
Force deduction solution summary 675- cutting trees for golf competition
Force deduction solution summary 905- array sorted by parity