Disable the cache in the volley library

  • Replies:0
Elyas Beshkani
  • Forum posts: 1

Jan 8, 2019, 8:24:21 AM via Website

Hello
sorry for my bad English!
this is my code for getting information
But information is cached
When I add a data to the database, the data will be added but will not be displayed
As long as I was on the localhost, it worked fine, but when uploaded to the host, the data cached
What can I do?
Thank you for helping me!
Another interesting point is that when I turn on vpn, data does not cache and the new data quickly displayed!
what should I do?
I got confused

StringRequest request = new StringRequest(Request.Method.POST, url, listener, errorListener) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
    Map<String, String> map = new HashMap<>();
    map.put("year", year);
    map.put("month", month);
    return map;
}
};
request.setShouldCache(false);
RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
queue.getCache().clear();
queue.add(request);
Be the first to answer