Skip to content

Implement image caching strategy with disk persistence #286

@RUKAYAT-CODER

Description

@RUKAYAT-CODER

Background

CachedImage already partially implemented. Enhance with disk caching (not just memory), cache expiration policy, and cache size management (max 100MB). Reuses cached images across sessions.

Description

Enhance image caching to persist to disk across sessions and manage cache size.

Current Behavior

Image cache limited to memory. Lost on app restart. No size management.

Expected Behavior

Images cached to disk (100MB max). Survives app restart. LRU eviction.

Impact

⚡ Instant image loading on repeat visits
💾 Reduced network traffic by 80%+ on revisits
📊 Better performance after session restart

Acceptance Criteria

  • Persist CachedImage cache to disk via AsyncStorage
  • Implement LRU eviction (max 100MB)
  • Track cache hits/misses in analytics
  • Images reuse cache across app sessions
  • Add cleanup on low storage warning
  • Test cache eviction logic
  • Document cache lifecycle
  • Monitor cache performance metrics

Implementation Hints

Use expo-file-system for disk caching. Implement LRU with Map. Track metadata (URL, size, timestamp). Clean on app start if needed.

Performance Metrics

Before:

  • memoryCache: 50 MB limit
  • surviveRestart: No

After (Target):

  • diskCache: 100 MB limit
  • surviveRestart: Yes - 80%+ hit rate on reload

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions