dio_cache_interceptor
4.0.7, released 5 months ago by cow-level.ovh
Dio HTTP cache interceptor with multiple stores respecting HTTP directives.
What it does
A Dio interceptor that caches HTTP responses using various storage backends (like memory, files, Hive, or Isar). It automatically respects standard HTTP caching directives such as ETag, Last-Modified, Age, and Cache-Control.
AI-written summary of version 4.0.7, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to cache HTTP responses made with Dio to reduce network traffic
- You want to support offline usage by falling back to cached responses on network failure
- You need granular control over cache policies per request
Skip it when
- You are not using Dio as your HTTP client
- You do not need HTTP response caching
Strengths
- Supports multiple storage backends including memory, file system, Hive, Isar, and Drift
- Respected standard HTTP cache directives and headers
- Allows offline fallback and error handling via cache
Weaknesses
- Requires additional packages to be installed separately for certain store implementations
- Tied specifically to the Dio HTTP client
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Add the dependency to pubspec.yaml and attach the interceptor to your Dio instance.
import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
final options = const CacheOptions(
store: MemCacheStore(),
policy: CachePolicy.request,
hitCacheOnNetworkFailure: true,
);
final dio = Dio()..interceptors.add(DioCacheInterceptor(options: options));
var response = await dio.get('https://www.foo.com');Alternatives
Packages that do the same job and could replace dio_cache_interceptor.
- http_cache_hive_store
Hive cache store implementation for HTTP and Dio clients using hive_ce.
79Compare - http2
An HTTP/2 implementation in Dart for low-level transport and pooled HTTP/2 requests.
91Compare - dio_web_adapter
Web and WASM HTTP client adapter for Dio.
83Compare - alice_dio
Dio interceptor and network logger for Alice network inspector UI
82Compare
Works with
Packages commonly used together with dio_cache_interceptor: ones it builds on, ones built on it, and its own family.
- diodio_cache_interceptor depends on itA powerful HTTP networking package for Dart and Flutter with interceptors and request cancellation.
- flutter_map_cacheBuilt on dio_cache_interceptorA slim caching plugin for flutter_map tile layers supporting multiple storage backends.
- nominatim_flutterBuilt on dio_cache_interceptorFlutter plugin for Nominatim reverse geocoding, place searches, lookups and caching.