Question

Is it possible to modify the expiration policy for the cache on Google's Volley lib? I believe you can implement your own cache, however is there an easy way to do this with the default implementation?

Était-ce utile?

La solution 2

It seems that currently the cache expiration is controlled solely by the "Cache" headers in the response so basically you are left to the mercy of the server. Whatever server returns in the "Expires" or "max-age=" that will be used. We will have to use our own cache if we need custom expiry policy...

Autres conseils

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

There is an example in my answer to similar question - Android Volley + JSONObjectRequest Caching

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top