dio-http-cache icon indicating copy to clipboard operation
dio-http-cache copied to clipboard

How to fetch from cache if available but still load from network in background

Open damms005 opened this issue 5 years ago • 5 comments

Thanks for this awesome package.

Please I have a scenario whereby I want my app to be very responsive. At same time, I want it to have updated content. So, I am trying to implement this requirement:

  1. If resources does not exist in cache, load from internet and save to cache
  2. If resource exists in cache, immediately return cached content but refresh cache in the background.

However, I am open to other alternatives to this design as long as it achieves the aim

damms005 avatar Sep 18 '20 12:09 damms005

Thanks for your advice, that's a good idea. I'll think about it later

hurshi avatar Sep 24 '20 08:09 hurshi

Great job @hurshi I need this too.

allanwolski avatar Oct 14 '20 17:10 allanwolski

Great idea, if there is a way you to handle this it would be very usefull

danielweil avatar Oct 23 '20 13:10 danielweil

I need this function too. Is there any way that we can do it base on current code? ex, check cache exist by key? if cache exist, return it and fire another request at background.

dodatw avatar Dec 27 '20 15:12 dodatw

Any news?

xVemu avatar Sep 15 '22 11:09 xVemu