Overview
Dio HTTP Cache is a caching library for Flutter's Dio HTTP client, providing both in-memory and disk-based caching. It uses sqflite for persistent storage on disk and implements an LRU (Least Recently Used) strategy via google/quiver-dart for efficient memory management. This package helps reduce redundant network requests, improve app performance, and save bandwidth by caching HTTP responses. Ideal for apps requiring offline support or frequent API calls with stable data.
Use cases
- Caching API responses to reduce network usage
- Enabling offline access to previously fetched data
- Improving app performance with reduced latency
- Storing frequently accessed data efficiently
- Reducing server load through cached responses
Key features
- Disk caching using sqflite
- LRU memory cache with quiver-dart
- Automatic request/response caching
- Configurable cache expiration
- Supports GET and HEAD requests
Suitable for
- Apps with frequent API calls
- Offline-capable applications
- Performance-optimized network layers
- Data-heavy mobile apps
- Developers using Dio for HTTP requests
Considerations
- Requires sqflite setup and permissions
- Cache size must be managed manually
- Not suitable for large binary data
- Limited to GET/HEAD methods
- May require custom cache key logic for complex requests