Set cache expiration policy using Google Volley

Can I change the cache expiration policy in Google Volley lib? I believe you can implement your own cache, however, is there an easy way to do this with the default implementation?

+19
android android-volley
May 28 '13 at 2:55
source share
2 answers

It seems that at present, cache expiration is controlled solely by the "cache" headers in the response, so basically you are left to the mercy of the server. Whichever server is returned in the "Expires" or "max-age =" that will be used. We will need to use our own cache if we need a special expiration policy ...

+17
May 29 '13 at 8:50
source share

No need to write your own cache implementation. You can change the com.android.volley.toolbox.HttpHeaderParser.parseCacheHeaders method (NetworkResponse answer), ignore these headers, set the entry.softTtl and entry.ttl fields for any value that works for you, and use your method in your query class .

My answer to a similar question has an example - Android Caching Volley + JSONObjectRequest

+22
May 31 '13 at 7:55
source share



All Articles