Cache does not respect stalePeriod on web

未关闭
#393 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
dart, flutter
领域
web-dev

调研方向

从 lib/src/config/_config_web.dart 开始,检查它如何选择存储提供程序。然后阅读 lib/src/storage/cache_info_repositories/non_storing_object_provider.dart 和 lib/src/cache_store.dart,重点关注 getOldObjects 和 stalePeriod 的处理。重现一分钟的 Web 场景,并确认已过期的项目会被移除,使下一次请求能够访问网络。

由索引模型根据 Issue 内容生成。

描述

🐛 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:

  • [✓] 🌏 Web
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.

主要语言
Dart
星标
814
派生
513
平均合并
7 小时 34 分钟
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Baseflow/flutter_cache_manager 的其他 Issue

查看 Baseflow/flutter_cache_manager 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。