问题描述
我有一个web视图的活动,并希望缓存内容。在默认情况下,它不显示为使用缓存
I have an activity with a WebView and want to cache content. By default, it does not appear to be using the cache.
Android的 WebSettings 有几个不同的缓存相关的常量。
Android's WebSettings has several different cache-related constants.
当我设置缓存模式,以LOAD_CACHE_ELSE_NETWORK,它似乎使用缓存。不过,我不希望使用过期的缓存内容。
When I set the cache mode to 'LOAD_CACHE_ELSE_NETWORK', it appears to use the cache. However, I don't want to use expired cache content.
这让我使用:
- LOAD_DEFAULT:默认的缓存使用模式或
- LOAD_NORMAL:普通缓存的使用模式
但文件并没有细说什么是正常和默认的意思。
But the documentation does not elaborate on what "normal" and "default" mean.
如何在这两种模式有什么不同?
How do these two modes differ?
推荐答案
我同意,人们会想到NORMAL_MODE是默认模式,但很明显这是两个不同的值。
I agree, one would expect that NORMAL_MODE is the default mode, but clearly this is two different values.
我想回答问题2(LOAD_NORMAL)中的
I think answer to question 2. (LOAD_NORMAL) is answered in the documentation for WebSettings.setCacheMode(int mode)
对于一个正常的页面加载,缓存进行检查,并根据需要的内容重新验证。导航时回来,内容不重新验证,而不是内容只是从缓存中拉出。此功能允许客户端覆盖此行为。
这篇关于LOAD_DEFAULT和LOAD_NORMAL为WebSettings之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!