【发布时间】:2016-10-14 18:11:24
【问题描述】:
实际上,我对凌空缓存管理有点困惑。假设我有一个带有 BASE URL http://example.com 的 API,但是当我调用我的 api 时,我附加了一个布局参数,所以最后它看起来像 http://example.com?sort_by=distance。
因此,如果我想清除此 url 的缓存,我应该使用哪个键
http://example.com 或 http://example.com?sort_by=distance
如果答案是第二个,那么我是否需要为由不同 url 参数创建的所有 url 独立清除缓存。
【问题讨论】:
-
这在我看来就像您正在访问一个不缓存数据的网络服务...
-
我的网站让我缓存 url 数据。但有时当我收到更新标志时,我需要清除缓存并再次调用 api。
-
在Request.java /**
* Returns the cache key for this request. By default, this is the URL. */ public String getCacheKey() { return getUrl(); }然后public Request(int method, String url, Response.ErrorListener listener) { mMethod = method; mUrl = url; mErrorListener = listener; setRetryPolicy(new DefaultRetryPolicy()); }
标签: android caching android-volley