-
-
Notifications
You must be signed in to change notification settings - Fork 710
Description
🚀 Feature Requests
The cached_network_image
package is widely used to improve image loading performance in Flutter apps by caching network images. However, there are cases where the image URLs become invalid or the image content is removed from the server (e.g., deleted user-generated content).
Currently, the library continues to re-fetch these removed images even though they're no longer needed, causing repeated HttpException: 404
errors. This behavior leads to unnecessary network requests, exception logs, and wasted resources.
════════ Exception caught by image resource service ════════════════════════════
HttpException: Invalid statusCode: 404, uri = {{image_url}}
════════════════════════════════════════════════════════════════════════════════
This feature would add more robust cache control and allow developers to prevent repeated failed image fetches by either setting an expiry on cached images or removing them programmatically.
Describe the feature
To add support for one or more of the following capabilities:
-
Cache Expiry Duration: Allow developers to set a
cacheDuration
. Once expired, the image would be re-fetched only if it’s still in use. -
Manual Cache Invalidation: Provide a public API such as
CachedNetworkImage.evictFromCache(String url)
to allow developers to explicitly remove unused or obsolete images from disk and memory cache. -
Automatic Removal After Repeated Failure: Automatically remove images from cache that continuously fail to load (e.g., after 3 consecutive 404s), assuming the resource is permanently gone.
These additions would give developers more control over image caching behavior, reduce unnecessary network traffic, and improve app stability when working with dynamic or short-lived content.
Platforms affected
- iOS
- Android