I am creating an Android application that uses Volley to download images from the Internet.
I use LruCachewith Volley to cache bitmaps in memory, and that's fine. In addition, I would like Volley to use the built-in http-disk-based cache support using HttpResponseCache .
I implemented an example in this link, but I noticed that nothing is cached in HttpResponseCache(I checked by fetching the HitCount field in the cache object).
After sniffing in the Volley source code, I found that Volley manually removes the cache flag when opened URLConnection:
private URLConnection openConnection(URL url, Request<?> request) throws IOException {
URLConnection connection = createConnection(url);
int timeoutMs = request.getTimeoutMs();
connection.setConnectTimeout(timeoutMs);
connection.setReadTimeout(timeoutMs);
connection.setUseCaches(false);
connection.setDoInput(true);
if ("https".equals(url.getProtocol()) && mSslSocketFactory != null) {
((HttpsURLConnection)connection).setSSLSocketFactory(mSslSocketFactory);
}
return connection;
}
Here you can see this code here: Volley - HurlStack (line 167)
, , HttpResponseCahce , .
: UseCaches URLConnections, / ?