llfbandit / dio_cache_interceptor

Dio HTTP cache interceptor with multiple stores respecting HTTP directives (ETag, Last-Modified, Cache-Control) with options.
https://pub.dev/packages/dio_cache_interceptor
120 stars 70 forks source link

Interceptor still caching an no-cache endpoint #127

Closed edeuss closed 1 year ago

edeuss commented 1 year ago

We have a few endpoints that are marked as no-cache, but the interceptor still has the second response be a 304 status code and with an empty data object.

I have the cache policy set to CachePolicy.request, I can't tell if this is an issue with the package or if I have set something up incorrectly.

llfbandit commented 1 year ago

What do you mean when you say "marked as no-cache" ?

If you set "no-cache" from request "Cache-Control" header, this does not mean the response will not be cached. For this, you can use "no-store" instead. Shortly, "no-cache" value forces a re-validation from the server. See documentation here.

edeuss commented 1 year ago

@llfbandit ok, but any reason why whenever the endpoint gets requested again it returns 304 with no data? Shouldn’t it used the cached data automatically?

llfbandit commented 1 year ago

Yes but I won't investigate further since I don't have any info of which store you use what you did, etc. Try to clear your store and test again.