Skip to content
pubscout

dio_cache_interceptor

4.0.7, released 5 months ago by cow-level.ovh

Dio HTTP cache interceptor with multiple stores respecting HTTP directives.

WASM-readyRock solid
$ flutter pub add dio_cache_interceptor
Source repository

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.

Works with

Packages commonly used together with dio_cache_interceptor: ones it builds on, ones built on it, and its own family.