cachecontrol 0.1.0+1 copy "cachecontrol: ^0.1.0+1" to clipboard
cachecontrol: ^0.1.0+1 copied to clipboard

Dart only (no dependencies) package to parse and format HTTP Cache-Control header.

cache-control #

Dart only (no dependencies) package to parse and format HTTP Cache-Control header.

Getting started #

$ flutter pub add cachecontrol

API #

HTTP requests can have a Cache-Control header for both the request and response header.

Cache-Control: max-age=604800, stale-if-error=86400

To parse request headers:

final headers = <String, String>{'Cache-Control': 'max-age=604800, stale-if-error=86400'}
final cacheControl = RequestCacheControl.parse(headers['Cache-Control']!);

To parse response headers:

final headers = <String, String>{'Cache-Control': 'max-age=604800, stale-if-error=86400'}
final cacheControl = ResponseCacheControl.parse(headers['Cache-Control']!);

Contributing #

Contributions are welcome. Please open up an issue or create PR if you would like to help out.

Make sure to run dart format and dart test before submitting a PR.

FAQ #

Why another cache-control library?

None of the existing libraries focus on just parsing the Cache-Control headers. There are some that expose Express (or connect-like) middlewares, and some unmaintained other ones that do rudimentary parsing of the header. The idea of this module is to parse the header according to the RFC with no further analysis or integration.

See also #

4
likes
140
points
331
downloads

Publisher

verified publisherrodydavis.com

Weekly Downloads

Dart only (no dependencies) package to parse and format HTTP Cache-Control header.

Repository (GitHub)

Documentation

API reference

License

Apache-2.0 (license)

More

Packages that depend on cachecontrol