Skip to main content
Sonamu provides frequently used compression patterns as CompressPresets. You can easily configure compression by selecting the appropriate preset for your situation.

CompressPresets Overview

Complete Preset List

disabled

Disable compression

default

Default settings (1KB, br/gzip/deflate)

aggressive

Aggressive compression (256B)

conservative

Conservative compression (4KB, gzip only)

gzipOnly

gzip only

Preset Details

disabled

Completely disables compression.

default

Balanced default settings.
Characteristics:
  • Under 1KB: No compression (prevents overhead)
  • 1KB and above: Compression in order of brotli > gzip > deflate
  • Modern browsers: brotli (best compression ratio)
  • Legacy browsers: gzip (compatibility)

aggressive

Aggressive compression for bandwidth optimization.
Effects:
  • Compresses everything 256 bytes and above
  • Minimizes network transfer volume
  • Slight increase in CPU overhead

conservative

Conservative compression that minimizes CPU load.
Characteristics:
  • Under 4KB: No compression
  • Excludes brotli (saves CPU)
  • Uses gzip only (fast + compatible)

gzipOnly

Configuration that uses only gzip.
Characteristics:
  • Fastest compression
  • Supported by all browsers
  • Stable

Preset Comparison Table

Compression Ratio Comparison

Based on actual 100KB JSON data:

Production API Server

Mobile App Backend

High-Performance Real-Time API

Legacy Browser Support

Development Environment

Combining Presets

You can customize based on presets.

Per-API Presets

Environment-Based Presets

Precautions

Precautions when using presets:
  1. Presets are starting points: Adjust according to your situation
  2. aggressive increases CPU load: Monitor server performance
  3. conservative doesn’t compress small responses: Reduced network efficiency
  4. disabled disables all compression: Increased transfer volume

Performance Measurement

Performance comparison by preset (based on 100KB JSON): Conclusion: brotli takes slightly longer to compress but is overall faster due to network time savings

Next Steps

Compression Configuration

Global compression plugin settings

Per-API Control

Compression settings in @api decorator

Performance Optimization

Compression optimization strategies