Set expiration policy for cache using Google's Volley

前端 未结 2 500
夕颜
夕颜 2020-12-13 07:10

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 wi

2条回答
  •  天涯浪人
    2020-12-13 07:38

    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

提交回复
热议问题