Skip to content

Brotli Compression

Zuno includes built-in support for Brotli, a modern compression algorithm that offers better compression ratios than Gzip. This extension automatically compresses HTTP responses when the client supports it—reducing bandwidth usage and improving load times.


To enable Brotli compression globally, register the extension using app.use():

app.use(compression());

Zuno will automatically:

  • Detect if the client accepts br encoding
  • Compress the response body using Brotli
  • Set the appropriate Content-Encoding: br header

#include <zuno/zuno.hpp>
int main() {
zuno::App app;
app.use(compression());
app.get("/data", [](Request& req, Response& res) {
std::string largePayload = generateLargeJson();
res.send(largePayload);
});
app.listen(3000);
}

When a client sends:

GET /data HTTP/1.1
Accept-Encoding: br

Zuno responds with:

HTTP/1.1 200 OK
Content-Encoding: br
Content-Type: application/json
...compressed body...

  • Brotli is only applied to responses above a certain size threshold (e.g. 1KB)
  • Binary files (e.g. images, videos) are typically excluded
  • Clients that do not support Brotli will receive uncompressed responses

  • Use Brotli for large JSON, HTML, or text-based responses
  • Avoid compressing already-compressed formats (e.g. .zip, .png)
  • Monitor CPU usage in high-throughput environments

Explore more extensions:


Zuno’s Brotli compression extension helps you deliver faster, leaner responses—without sacrificing clarity or control.