hurshi / dio-http-cache

http cache lib for Flutter dio like RxCache
Apache License 2.0
274 stars 223 forks source link

Cache doesn't return any data if the duration of max stale has passed, even if the cache Duration itself hasn't passed. #49

Closed NamanShergill closed 4 years ago

NamanShergill commented 4 years ago

According to the documentation:

Example for maxAge and maxStale #


 _dio.post(
    "https://www.exmaple.com",
    data: {'k': "keyword"},
    options:buildCacheOptions(
        Duration(days: 3), 
        maxStale: Duration(days: 7), 
    )
 )

0 ~ 3 days : Return data from cache directly (irrelevant with network). 3 ~ 7 days: Get data from network first. If getting data from network succeeds, refresh cache. If getting data from network fails or no network avaliable, try get data from cache instead of an error. 7 ~ ∞ days: It won't use cache anymore, and the cache will be deleted at the right time.

Yet it is not getting the data from the cache in the 3-7 days range, instead it just throws an error of failed host lookup (Airplane mode was turned on to test this). Any solutions to this?

NamanShergill commented 4 years ago

Nevermind, I am an idiot. I assigned them the value backwards.