Baseflow / Baseflow/flutter_cache_manager
Cache does not respect stalePeriod on web
- Ngôn ngữ chính
- Dart
- Star
- 809
- Fork
- 510
- Merge trung bình
- 6 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
## 🐛 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:**
- [✓] :earth_asia: Web
### Cause
By default, the [config for web uses the NonStoringObjectProvider](https://github.com/Baseflow/flutter_cache_manager/blob/3bd49b866d9b5e6ce09d2283f0ef97488be97e1d/flutter_cache_manager/lib/src/config/_config_web.dart#L19). Old cache objects are removed [using their provider's getOldObjects method](https://github.com/Baseflow/flutter_cache_manager/blob/205387b4c7e4faff5152848b68c98d36e989ec01/flutter_cache_manager/lib/src/cache_store.dart#L143). The implementation of this in the NonStoringObjectProvider [never does anything](https://github.com/Baseflow/flutter_cache_manager/blob/3bd49b866d9b5e6ce09d2283f0ef97488be97e1d/flutter_cache_manager/lib/src/storage/cache_info_repositories/non_storing_object_provider.dart#L38).
Ideally, the web config should be update to use a repo that has a working implementation of `getOldObjects`.
Hướng dẫn đóng góp
Hướng nghiên cứu
Start with lib/src/config/_config_web.dart and inspect how it selects the storage provider. Then read lib/src/storage/cache_info_repositories/non_storing_object_provider.dart and lib/src/cache_store.dart, focusing on getOldObjects and stalePeriod handling. Reproduce the one-minute web scenario and confirm that an expired item is removed so the next request reaches the network.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- dart, flutter
- Lĩnh vực
- web-dev
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 58/100