Compression usually helps, but not always — here's how to decide
Whether you should compress files on Bunny.net depends on what you're storing and how your visitors access it. Compression reduces file size, which saves bandwidth and speeds up downloads for most users. But compression also uses CPU power when files are served, and some file types don't compress well enough to be worth the effort. The right choice depends on your specific content and traffic patterns.
Bunny.net supports compression through Brotli and Gzip, which are applied automatically to text-based files like HTML, CSS, and JavaScript when a visitor's browser supports them. For images, video, and already-compressed files, compression typically wastes resources without meaningful benefit. Understanding which files benefit from compression — and which don't — lets you configure your CDN efficiently without guessing.
Key Takeaways
- Text files like HTML, CSS, JavaScript, and JSON compress well and should be compressed; Bunny.net handles this automatically for browsers that support it.
- Images (JPEG, PNG, WebP) and video (MP4, WebM) are already compressed and gain little or nothing from additional compression.
- Compression saves bandwidth and improves load times for visitors on slower connections, but uses CPU resources on Bunny.net's servers.
- You can enable or disable compression per file type in Bunny.net's pull zone settings, or let the default behavior handle it for you.
- Monitor your actual bandwidth usage and load times after enabling compression to confirm it's helping your specific traffic.
Which file types compress well
Text-based files compress extremely well because they contain a lot of repetition. HTML files often repeat the same tags, CSS files repeat selectors and properties, and JavaScript files repeat function names and keywords. Brotli and Gzip can shrink these files by 60 to 80 percent, which means a 100 KB JavaScript file becomes 20 to 40 KB after compression.
JSON, XML, and SVG files also compress well for the same reason — they're text with structure and repetition. If you serve configuration files, API responses, or vector graphics, compression will noticeably reduce the bytes transferred. Plain text files and source maps follow the same pattern.
Bunny.net compresses these files by default when a visitor's browser sends the Accept-Encoding header (which nearly all modern browsers do). You don't need to do anything to enable this — it happens automatically.
Which file types don't benefit from compression
Images in JPEG, PNG, WebP, and AVIF format are already compressed using algorithms designed specifically for visual data. Running Gzip or Brotli on top of that compression typically reduces the file size by only 1 to 3 percent — not worth the CPU cost. The same applies to video files like MP4, WebM, and MKV, which use video codecs that are far more efficient than general-purpose compression.
Audio files (MP3, AAC, OGG) are also pre-compressed and won't shrink meaningfully. PDF files, ZIP archives, and other already-compressed formats fall into the same category. If you compress these files on Bunny.net, you're spending server CPU to save almost nothing.
The exception is if you're serving a very large number of small images or audio files where even a 1 to 2 percent saving adds up across your entire catalog. In most cases, though, it's not worth enabling.
How compression affects your bandwidth and speed
Compression reduces the bytes sent over the network, which directly lowers your bandwidth bill. A visitor downloading a 500 KB HTML page that compresses to 100 KB uses 400 KB less bandwidth. Over thousands of visitors, that adds up. Bunny.net charges per gigabyte transferred, so compression can meaningfully reduce your costs if you serve a lot of text content.
Compression also improves perceived speed for visitors on slower connections. A 100 KB file downloads faster than a 500 KB file, even on a fast connection. For mobile users or people in regions with slower internet, the difference is noticeable.
The tradeoff is that compression uses CPU resources on Bunny.net's edge servers. The server has to compress the file before sending it (or decompress it if it was pre-compressed). For most modern CDNs, this cost is negligible — the bandwidth savings far outweigh the CPU cost. But if you're serving millions of requests per day, the CPU overhead becomes measurable.
How to configure compression in Bunny.net
Log into your Bunny.net account and open the pull zone you want to configure. Go to the Caching section and look for Compression settings. You'll see options to enable or disable compression, and sometimes to choose between Brotli and Gzip (Brotli is newer and compresses better, but older browsers may not support it).
By default, Bunny.net enables compression for text files and disables it for images and video. This is the right setting for most users — you don't need to change it. If you want to disable compression entirely (for example, if you're pre-compressing files yourself), you can turn it off here. If you want to enable compression for specific file types, you can usually do that through MIME type rules.
After you change compression settings, the change takes effect within a few minutes. Clear your browser cache or wait for the old cached version to expire before testing, or you'll see the old uncompressed version.
Pre-compression: doing it yourself instead
Some users pre-compress files on their origin server and upload the compressed version to Bunny.net. This means the server doesn't have to compress on every request — it just serves the pre-compressed file. This approach saves CPU on Bunny.net's edge servers and can be useful if you're serving extremely high traffic.
To pre-compress, you compress your files locally (using a tool like gzip or brotli), upload both the original and compressed versions to your origin, and configure your origin server to serve the compressed version when a browser requests it with the right Accept-Encoding header. Bunny.net will then pass through the pre-compressed file without re-compressing it.
For most users, this is unnecessary complexity. Bunny.net's automatic compression is efficient enough. Pre-compression makes sense only if you're serving millions of requests per day and monitoring shows that compression CPU is a bottleneck.
Monitoring compression to see if it's helping
Bunny.net's analytics dashboard shows bandwidth usage and request counts, but doesn't directly show compression savings. To measure the impact, compare your bandwidth usage before and after enabling compression. If you enable compression on a pull zone that previously had it disabled, you should see bandwidth drop by 50 to 70 percent for text-heavy sites, or 5 to 15 percent for sites with mostly images.
You can also check individual requests in your browser's developer tools. Open the Network tab, load a page, and look at the Size column. It shows two numbers: the transferred size (what was sent over the network) and the resource size (the uncompressed size). If transferred size is much smaller than resource size, compression is working. If they're similar, compression isn't helping — either the file was already compressed or the browser doesn't support it.
If you see no bandwidth improvement after enabling compression, and your traffic is mostly images or video, disable it. You'll save CPU on Bunny.net's servers without losing any benefit.
Frequently Asked Questions
Does Bunny.net compress files by default?
Yes. Bunny.net automatically compresses text files (HTML, CSS, JavaScript, JSON) using Brotli or Gzip when a visitor's browser supports it. Images and video are not compressed by default because they're already compressed. You don't need to enable anything — it works out of the box.
Will compression slow down my site?
No. Compression reduces file size, which speeds up downloads for visitors. The CPU cost of compression on Bunny.net's servers is negligible compared to the bandwidth savings. You might see a tiny delay on the first request (while the file is being compressed), but subsequent requests are cached, and the overall effect is faster load times.
Should I compress images myself before uploading to Bunny.net?
Yes, but not with Gzip or Brotli. Use an image optimizer like TinyPNG, ImageOptim, or Squoosh to reduce image file size. These tools use image-specific compression that's far more efficient than general-purpose compression. Then upload the optimized image to Bunny.net. Don't use Gzip compression on images — it won't help.
What's the difference between Brotli and Gzip?
Brotli compresses better than Gzip (usually 10 to 20 percent smaller), but older browsers don't support it. Gzip is supported by virtually every browser. Bunny.net uses Brotli for browsers that support it and falls back to Gzip for older ones. You don't need to choose — Bunny.net handles it automatically.
Can I disable compression for specific file types?
Yes, through Bunny.net's pull zone settings. You can set compression rules based on MIME type or file extension. For example, you could disable compression for .woff2 font files if they're already compressed. Most users don't need to do this — the default settings are optimal.