Compression trades file size for the time it takes to open them

File compression makes a file smaller by removing redundant data — think of it like vacuum-sealing a bag of clothes. A compressed file takes up less space on your device and moves faster over the internet. The catch: your computer has to decompress it (unseal it) before you can use it, which takes a few extra seconds. Whether that trade-off makes sense depends entirely on what you're doing with the file.

Bunny.net is a content delivery network — a service that stores copies of your files on servers around the world so people can read them faster. If you're using Bunny.net to host files, compression can cut your storage bill and make downloads quicker for users far from your main server. But if you're compressing files that are already small, or files that don't compress well, you're adding work for no real gain.

Key Takeaways

  • Compress files that are text-heavy, like PDFs, Word documents, or code — they shrink by 50 to 80 percent and decompress when ready.
  • Do not compress files that are already compressed, like JPEGs, MP4s, or ZIP files — you'll waste processing power and barely reduce the size.
  • On Bunny.net, compression saves money on storage and bandwidth if your users are downloading from distant regions, but adds a small delay when they open the file.
  • Enable compression at the Bunny.net level (in your pull zone settings) rather than pre-compressing files yourself — the service handles it automatically for supported file types.

What actually gets smaller when you compress

Text compresses extremely well because text files contain a lot of repetition. A PDF with the same header on every page, a Word document with repeated formatting, or a JSON file with many similar data structures can shrink to 20 to 40 percent of the original size. Plain text files compress even more — sometimes to 10 percent. These are the files where compression is worth doing.

Images and video barely compress at all because they're already compressed when you save them as JPEG, PNG, or MP4. These formats use mathematical tricks to throw away information your eye won't notice. Running compression again on a JPEG is like trying to squeeze water out of a sponge that's already been wrung out — you get almost nothing and waste CPU cycles doing it. The same applies to audio files in MP3 or AAC format.

How compression works on Bunny.net

Bunny.net can compress files on the fly, meaning it compresses them only when someone requests them, not when you upload them. You turn this on in your pull zone settings under "Compression" and select which file types to compress — typically HTML, CSS, JavaScript, JSON, XML, and plain text. When a user downloads one of these files, Bunny.net compresses it, sends the smaller version, and the user's browser decompresses it automatically. The whole process takes milliseconds.

You do not need to pre-compress files yourself and upload them already zipped. In fact, you should not, because Bunny.net can only serve one version of a file at a time. If you upload a .gz file, users get the .gz file and have to manually decompress it. If you let Bunny.net handle compression, users with modern browsers get the compressed version transparently, and older browsers get the uncompressed version instead.

When compression saves money and when it doesn't

Bunny.net charges for storage and for bandwidth (data transferred). If your site serves mostly text, HTML, and code, enabling compression can cut bandwidth costs by 60 to 75 percent. A 500 KB JavaScript file becomes 150 KB. Over thousands of downloads, that adds up. If your site serves mostly images and video, compression does almost nothing — you'll save 2 to 5 percent at best, and you'll pay for the CPU time to compress and decompress.

Storage savings are smaller. A compressed file takes up less space in Bunny.net's storage, but the difference is only meaningful if you're storing gigabytes of text. If you're hosting a blog or a web app, you probably won't notice. If you're hosting thousands of PDFs or log files, compression can cut your storage bill by half.

The real cost: latency and CPU

Compression adds a tiny delay. Bunny.net has to compress the file before sending it, and the user's browser has to decompress it after receiving it. For text files, this is usually under 50 milliseconds — fast enough that users won't notice. For very large files, the delay can be a few hundred milliseconds. If your users are on slow connections or old devices, decompression can take longer.

You also pay a small CPU cost. Bunny.net runs compression on its servers, which uses processing power. The service absorbs this cost, but it's one reason why compression is most useful when the file is large and compresses well. Compressing a 10 KB file saves almost nothing and wastes CPU cycles.

How to decide for your own files

Ask yourself three questions: What type of files am I serving? How far are my users from my origin server? How much bandwidth am I using? If you're serving mostly HTML, CSS, JavaScript, JSON, or plain text, turn compression on in Bunny.net — it will save bandwidth and money with almost no downside. If you're serving mostly images, video, or audio, leave compression off. If you're serving a mix, enable compression for text types only, which Bunny.net lets you do by file extension.

If your users are all in one region close to your origin server, compression saves less bandwidth because the distance is short anyway. If your users are spread globally, compression is more valuable because it reduces the amount of data traveling long distances. Check your Bunny.net analytics to see where your traffic comes from and how much bandwidth you're using per file type.

Frequently Asked Questions

Will compression break my website or files?

No. Modern browsers handle decompression automatically and transparently. Users will not see a .gz file or be asked to unzip anything. Bunny.net only compresses file types that are safe to compress and only sends compressed versions to browsers that support it.

Should I compress files before uploading them to Bunny.net?

No. Let Bunny.net handle compression through its pull zone settings. If you upload a pre-compressed file, users get the compressed file itself, not the original. Bunny.net's automatic compression is smarter because it can choose whether to compress based on the user's browser and connection.

Does compression help if I'm using a CDN in the same country as my users?

Yes, but less than if your users were far away. Compression still reduces bandwidth, which saves money and makes pages load slightly faster. The benefit is smaller because the distance is short, but it's not zero.

What file types should I compress?

Text-based files: HTML, CSS, JavaScript, JSON, XML, plain text, and SVG. Do not compress JPEG, PNG, GIF, WebP, MP4, MP3, or any file that already has a compression format in its name. Bunny.net lets you choose which extensions to compress in your pull zone settings.

Can I compress files that are already in a ZIP or RAR archive?

No. Archives are already compressed. Compressing them again wastes CPU and saves almost no space. Serve the archive as-is and let users read and extract it themselves.