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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
不要使用这些:
这些与默认的 webview 内部缓存无关。 Appcache 是一个完全不同的功能,它使您能够在没有互联网连接的情况下运行网站。它的效果不太好,可能您不想使用它。
通过设置:
viewer.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT)
就足够了。Don't use these:
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.
With setting this:
viewer.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT)
is enough.当然,缓存的方法应该更快。这就是缓存存在的确切原因。
但除非你专门禁用 webview 的缓存,否则应该没问题。如果不这样做 - 默认情况下它将使用缓存。
Of course, cached approach should be faster. That's the exact reason caching is there in the first place.
But you should be fine unless you specifically disable caching for webview. If you don't - it will use cache by default.
这里
setAppCacheEnabled(true)
在 Target SDK 33 中已弃用。请改用
settings.cacheMode = WebSettings.LOAD_DEFAULT
。Here
setAppCacheEnabled(true)
is deprecated in Target SDK 33.Use
settings.cacheMode = WebSettings.LOAD_DEFAULT
instead.利用这些设置;他们将帮助您缓存 WebView 内容:
Utilize these settings; they will assist you in caching WebView content: