在 Android webview 中缓存 [英] Caching in Android webview
问题描述
在Android webview中加载移动网页和非移动网页哪个更快;加载缓存还是根本不加载?
Which one is faster way to load mobile web pages and non mobile web pages in Android webview; loading cache or not loading that at all?
加载它的推荐样式是什么?
And what is recommend style to load that?
现在,当我不在所有非移动站点加载缓存时,加载速度比在本机浏览器中加载要慢得多.
Right now when I don't load cache at all non mobile sites are much more slower to load than when I load them in native browser.
推荐答案
不要使用这些:
viewer.getSettings().setAppCacheMaxSize(1024*1024*8);
viewer.getSettings().setAppCachePath("/data/data/com.your.package.appname/cache");
viewer.getSettings().setAppCacheEnabled(true);
这些与默认的 webview 内部缓存无关.Appcache 是一个完全不同的功能,它使您能够在没有互联网连接的情况下运行网站.它的效果不是很好,您可能不想使用它.
These have nothing to do with the default webview internal cache. Appcache is an entirely different feature mean to make you able to run the website w/o an internet connection. It does not work that great and probably you do not want to use it.
通过设置:viewer.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT)
就足够了.
With setting this: viewer.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT)
is enough.
这篇关于在 Android webview 中缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!