How to Auto Compress Files on Bunny.net

Bunny.net is a content delivery network (CDN) that includes built-in tools for optimizing how files are served to end users. One of its most practical features is automatic file compression — reducing the size of files before they reach a visitor's browser, without you having to manually compress anything. Here's how it works, what affects it, and what you need to think through before relying on it.

What Auto Compression Actually Does on Bunny.net

When a browser requests a file from a CDN, it sends a header indicating which compression formats it supports — most commonly Gzip or Brotli. If the CDN is configured to compress files automatically, it intercepts that request, compresses the file on the fly (or serves a cached compressed version), and delivers the smaller file to the browser. The browser then decompresses it transparently.

Bunny.net supports both Gzip and Brotli compression at the CDN edge level. Brotli generally achieves better compression ratios than Gzip, especially for text-based files, though support varies slightly by browser — all modern browsers handle both.

The key point: this compression happens at the edge, meaning Bunny.net's servers do the work, not your origin server. Your origin can still serve uncompressed files and Bunny.net handles the rest.

How to Enable Auto Compression in Bunny.net

Enabling compression on Bunny.net is straightforward through the Pull Zone settings:

  1. Log into your Bunny.net dashboard
  2. Navigate to CDN → Pull Zones
  3. Select the Pull Zone you want to configure
  4. Open the Optimization or Performance tab (depending on your dashboard version)
  5. Toggle on Bunny Optimizer or find the Compression options directly
  6. Enable Gzip and/or Brotli compression
  7. Save and deploy your changes

Some compression options are bundled under Bunny Optimizer, which is a broader performance suite. Enabling the full Optimizer activates additional features like image optimization and minification alongside compression — worth knowing if you only want compression without the rest.

What File Types Get Compressed 🗜️

Auto compression on Bunny.net is designed primarily for text-based file types, where compression delivers the most benefit:

File TypeCompressibleTypical Size Reduction
HTML✅ Yes60–80%
CSS✅ Yes60–80%
JavaScript (.js)✅ Yes60–75%
JSON / XML✅ Yes50–70%
SVG✅ Yes40–60%
Plain text (.txt)✅ YesVariable
JPEG / PNG / WebP❌ No benefitAlready compressed
MP4 / video files❌ No benefitAlready compressed
ZIP / RAR archives❌ No benefitAlready compressed

Binary files and media formats are already compressed using their own encoding — applying Gzip or Brotli on top adds overhead without reducing size. Bunny.net's auto compression is smart enough to skip these, but understanding this distinction matters when you're diagnosing why certain files aren't getting smaller.

Variables That Affect How Well It Works

Auto compression isn't a universal fix — several factors determine how much benefit you actually see:

Origin server configuration: If your origin is already compressing files before sending them to Bunny.net, there can be conflicts. A file compressed by your web server and then cached by Bunny.net in compressed form may behave unexpectedly if headers aren't set correctly. Generally, it's cleaner to let one layer handle compression consistently.

Cache headers and TTL settings: Bunny.net caches compressed versions of files. If your cache TTL (time-to-live) is very short or your origin sends no-cache headers, compressed versions may not be stored efficiently, reducing the performance gain.

File size: Compression has minimal impact on very small files (under ~1KB). The overhead of compression headers can sometimes outweigh the size reduction for tiny assets.

Bunny Optimizer vs. standalone compression: If you're using the full Bunny Optimizer suite, compression behavior may interact with other transformations like minification. Minified files compress even better, so the combination tends to perform well — but it adds another layer to troubleshoot if something goes wrong.

Pull Zone type: Bunny.net offers different Pull Zone configurations depending on your use case (standard CDN, video streaming, storage zones). Compression settings and behavior can differ slightly depending on which zone type you're working with.

Brotli vs. Gzip: Which Should You Enable?

Both are worth enabling when possible. Brotli offers stronger compression ratios — particularly for HTML and JavaScript — but requires HTTPS to work in most browser implementations. If your Pull Zone is serving content over HTTP only, Gzip is the reliable fallback.

Enabling both lets Bunny.net serve whichever format the requesting browser supports, which is the standard best practice for modern CDN setups. 🌐

Verifying Compression Is Working

After enabling compression, you can confirm it's active using browser developer tools or an HTTP header checker:

  • Open Chrome DevTools → Network tab
  • Click a served file (CSS, JS, or HTML)
  • Check the Response Headers for content-encoding: gzip or content-encoding: br

The presence of that header confirms compressed delivery. If it's absent, double-check that the Pull Zone settings were saved correctly and that the file type is one Bunny.net compresses.

You can also use tools like GTmetrix, WebPageTest, or KeyCDN's HTTP Header Checker to test remotely, which avoids browser caching interfering with local results.

The Setup-Dependent Part

How much auto compression improves your site's performance depends on factors specific to your deployment — how your origin server is configured, what your cache strategy looks like, whether you're using Bunny Optimizer's full feature set, and what types of files make up most of your traffic. A site heavy on JavaScript and HTML will see substantial gains. A site primarily serving images or video through storage zones will see almost none from compression alone. Those variables live in your own setup, and that's what shapes the real-world outcome.