Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Volley cache management

Is there a way I could disable the Volley cache management? My app is using Google Volley library to manage the transport layer, but I have my own cache manager implementation because the server does not uses Cache-Control header. I want to save the space that Volley cache is using because it is totally useless.

Is there any easy way? or should I implement my own version of RequestQueue?

Any suggestion appreciated.

like image 303
Proverbio Avatar asked Aug 15 '14 20:08

Proverbio


People also ask

How do I disable volley cache?

If you want to disable caching globally from the volley library, you can permanently set the mShouldCache variable to false in the Request class.

What is Volley used for in Android?

Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster. Volley is available on GitHub. Volley offers the following benefits: Automatic scheduling of network requests. Multiple concurrent network connections.


1 Answers

If you use any of the default Request classes implemented in volley(e.g. StringRequest, JsonRequest, etc.), then call setShouldCache(false) right before adding the request object to the volley RequestQueue:

request.setShouldCache(false); myQueue.add(request); 

If you have your own implementation of the Request class, then you can call setShouldCache(false) in the constructor of your class.

This solution disables caching for each requests individually. If you want to disable caching globally from the volley library, you can permanently set the mShouldCache variable to false in the Request class.

like image 109
Hungry Coder Avatar answered Sep 19 '22 23:09

Hungry Coder