hurshi / dio-http-cache

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

如何知道某次请求是否从缓存里读取数据? #47

Closed gzlock closed 4 years ago

gzlock commented 4 years ago

希望可以在使用了缓存的请求头部增加一个{"dio-http-cache":true}之类的值

gzlock commented 4 years ago

从这个概念来想,后续可以扩展到某次请求如果写入了缓存,可以在头部增加一个{'dio-http-cache-write':true}之类的

hurshi commented 4 years ago

您好,感谢您的 issue。 我在新版0.2.9 中已经新增了这个功能

// How to know if the data come from Cache
if (null != response.headers.value(DIO_CACHE_HEADER_KEY_DATA_SOURCE)) {
    // data come from cache
} else {
    // data come from net
}