user2391218
user2391218

Reputation: 412

Android volley caching -How to display stale cached data when there is no network connectivity?

I have cached the response from the server based on the headers sent by the server . The value of max age is 180 s .From what I understand if any request is made for the same url after 180 s volley frameworks replaces the cache with the updated version of the data from the server . I want to display the cached data when the network connectivity is not present . How can I implement this using android volley???

Upvotes: 1

Views: 552

Answers (1)

Jokin
Jokin

Reputation: 4218

in this case, hadle the network error and when it happens, get the data from the cache directly with mQueue.getCache().get(request.getCacheKey()), it will return the data if it's in the cache even if it's expired.

Upvotes: 2

Related Questions