Baseflow / Baseflow/flutter_cached_network_image
caching of 404 responses
- Dominant language
- Dart
- Stars
- 2.6k
- Forks
- 731
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 1
Description
## 🚀 Feature Requests
we fetching image like that which works pretty fine, with the exception of 404 response.
Then the image is requested again and again.
Don't know why they are not cached (status code or empty response?).
Headers should be correct (The images never change (when content change, the uri will change, so we set the immutable header).
```
CircleAvatar(
foregroundImage: userImage(_partner!),
backgroundImage: defaultImage(_partner!))
userImage(User partner) => (partner.pictureUrlDisplay != null)
// there is no configuration, image caching depends on cache control header send by the server
? CachedNetworkImageProvider(
partner.pictureUrlDisplay!,
headers: userImageHeaders,
errorListener: (err) {
_logger.w("failed to load image: $err");
},
)
: defaultImage(partner);
defaultImage(User partner) =>
AssetImage((partner.gender == "man") ? "assets/image_not_found_man.webp" : "assets/image_not_found_woman.webp");
```
### Describe the feature
allow caching of 404 image requests depending on cache headers.
Server already returns suitable header
`Cache-Control: immutable, max-age=86400`
If needed add config similar to CacheOptions in DioCacheInterceptor
```hitCacheOnErrorExcept: [403, 503, 521], // do not cache temporary errors```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.