dio_cache_plus
2.1.0, released 3 weeks ago by balu.dev
Advanced Dio interceptor that adds flexible caching, expiry and deduplication.
What it does
Provides per‑request control over caching, conditional rules, absolute or relative expiry, and request deduplication for Dio HTTP calls. Stores cached responses persistently using Hive and adds standard Cache‑Status headers.
AI-written summary of version 2.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need fine‑grained caching for Dio requests
- You want automatic cache expiry and deduplication
Skip it when
- You are not using Dio as your HTTP client
- You need a lightweight solution without persistent storage
Strengths
- Highly configurable per‑request caching
- Supports both duration and absolute expiry
- Persistent cross‑platform storage with Hive
- Request deduplication reduces network load
Weaknesses
- Adds complexity compared to plain Dio
- Relies on Hive which may increase app size
- Only works with Dio, not other HTTP clients
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
import 'package:dio/dio.dart';
import 'package:dio_cache_plus/dio_cache_plus.dart';
final dio = Dio();
dio.interceptors.add(DioCachePlusInterceptor(cacheAll:false,commonCacheDuration:const Duration(minutes:5)));
final response = await dio.get('/api/data',options: Options().setCaching(enableCache:true));Alternatives
Packages that do the same job and could replace dio_cache_plus.
Works with
Packages commonly used together with dio_cache_plus: ones it builds on, ones built on it, and its own family.
- cryptodio_cache_plus depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- diodio_cache_plus depends on itA powerful HTTP networking package for Dart and Flutter with interceptors and request cancellation.
- hivedio_cache_plus depends on itFast, pure Dart key-value store with optional AES-256 encryption
- hive_flutterdio_cache_plus depends on itFlutter extension for Hive providing easy initialization and adapters for common types.