Skip to content

Feature: Avoid Retrying Removed Image After Repeated 404 Errors #1018

@shamnad-sherief

Description

@shamnad-sherief

🚀 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions