Skip to content
pubscout

shelf_gzip

4.1.0, released 3 years ago by jpryan.me

Shelf middleware to GZIP encode HTTP responses.

$ flutter pub add shelf_gzip
Source repository

What it does

Shelf middleware that automatically applies GZIP compression to HTTP responses based on content type and compression level. It skips compression for already compressed content types or small response bodies.

AI-written summary of version 4.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are building a Dart backend using the shelf package and want to compress responses.
  • You want to optimize bandwidth usage for text or code content served by your shelf server.

Skip it when

  • You are not using the shelf package for your backend.
  • Response bodies are consistently smaller than 512 bytes and will not benefit from compression.

Strengths

  • Easy integration with shelf pipelines via gzipMiddleware.
  • Allows customization of compression level and compression scope.
  • Automatically skips already compressed content types.

Weaknesses

  • Limited to the shelf ecosystem.
  • Not documented for non-shelf frameworks.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1

Not documented

var handler = const shelf.Pipeline().addMiddleware(gzipMiddleware).addHandler(staticHandler);

Alternatives

Packages that do the same job and could replace shelf_gzip.

Works with

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