Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rodydavis/http_get_cache
HTTP compliant cache for Dart and Flutter. This package is a wrapper around the http package that provides a simple way to cache responses using the 'Cache-Control', 'eTag' and 'Last-Modified' headers.
https://github.com/rodydavis/http_get_cache
cache-control dart flutter http
Last synced: 21 days ago
JSON representation
HTTP compliant cache for Dart and Flutter. This package is a wrapper around the http package that provides a simple way to cache responses using the 'Cache-Control', 'eTag' and 'Last-Modified' headers.
- Host: GitHub
- URL: https://github.com/rodydavis/http_get_cache
- Owner: rodydavis
- License: apache-2.0
- Created: 2024-07-18T16:23:43.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-02T19:48:46.000Z (2 months ago)
- Last Synced: 2024-10-03T07:42:53.704Z (about 1 month ago)
- Topics: cache-control, dart, flutter, http
- Language: Dart
- Homepage:
- Size: 1.96 MB
- Stars: 20
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# http_get_cache
HTTP compliant cache for Flutter. This package is a wrapper around the `http` package that provides a simple way to cache responses using the 'Cache-Control', 'eTag' and 'Last-Modified' headers.
## Dart
```dart
import 'package:http_get_cache/http_get_cache.dart';void main() async {
...
await initHttpGetCache(cachePath: '.cache', databasePath: '.db');// Create a new HTTP Client
final client = httpClient();// Future
final res = await client.send('...');// Stream
final res = await client.stream('...');
}
```## Flutter
In the `main.dart` file you can add the following code:
```dart
import 'package:http_get_cache/http_get_cache_flutter.dart';void main() async {
...
await initFlutterHttpGetCache();
// Create a new HTTP Client
final client = httpClient();// Future
final res = await client.send('...');
// Stream
final res = await client.stream('...');
}
```When building the Flutter app you can remove the default client with the following variable:
```
--dart-define=no_default_http_client=true
```## Wrap with RetryClient
```dart
import 'package:http/retry.dart';final client = RetryClient(httpClient());
```## Install via git:
```yaml
http_get_cache:
git:
url: https://github.com/rodydavis/http_get_cache
```## See also
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
- https://www.mnot.net/cache_docs/
- https://jakearchibald.com/2016/caching-best-practices/
- https://csswizardry.com/2019/03/cache-control-for-civilians/
- https://httpwg.org/specs/rfc9111.html
- https://httpwg.org/specs/rfc5861.html
- https://httpwg.org/specs/rfc8246.html