Baseflow / flutter_cache_manager

Generic cache manager for flutter
https://baseflow.com
MIT License
739 stars 427 forks source link

Cache does not respect stalePeriod on web #393

Open jimcullenaus opened 1 year ago

jimcullenaus commented 1 year ago

🐛 Bug Report

When setting a custom stalePeriod on web, the cache remains valid and the browser will access data via the cache rather than sending out a fresh network request, even when the Duration specified in stalePeriod has expired.

Expected behaviour

On all platforms, after a custom stalePeriod is set, items should be removed from the cache after the specified Duration has expired.

Reproduction steps

  1. Extend CacheManager with a Config(...stalePeriod: Duration(minutes: 1)
  2. Make a request that uses the CacheManager
  3. Wait over one minute
  4. Make the same request again

Observe that the second request hits the cache, not the web.

Configuration

Version: 3.3.0

Platform:

Cause

By default, the config for web uses the NonStoringObjectProvider. Old cache objects are removed using their provider's getOldObjects method. The implementation of this in the NonStoringObjectProvider never does anything.

Ideally, the web config should be update to use a repo that has a working implementation of getOldObjects.