Salvo is an extremely simple and powerful Rust web backend framework. Only basic Rust knowledge is required to develop backend services.
salvo-compression
Compression middleware for the Salvo web framework that automatically compresses HTTP responses, reducing bandwidth usage and improving load times.
Features
- Multiple algorithms: Gzip, Brotli, Deflate, and Zstd compression
- Content negotiation: Automatically selects the best algorithm based on client's
Accept-Encodingheader - Configurable compression levels: Choose between fastest, default, best compression, or precise control
- Content type filtering: Only compress appropriate MIME types (text, JSON, etc.)
- Minimum length threshold: Skip compression for small responses that wouldn't benefit
Supported Algorithms
| Algorithm | Feature | Content-Encoding |
|---|---|---|
| Gzip | gzip |
gzip |
| Brotli | brotli |
br |
| Deflate | deflate |
deflate |
| Zstd | zstd |
zstd |
Installation
This is an official crate, so you can enable it in Cargo.toml:
= { = "*", = ["compression"] }
Quick Start
use *;
use ;
async
async
Documentation & Resources
☕ Donate
Salvo is an open source project. If you want to support Salvo, you can ☕ buy me a coffee here.
⚠️ License
Salvo is licensed under either of
-
Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0).
-
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT).