# Automatically compress served content

**URL:** <https://answers.netlify.com/t/automatically-compress-served-content/31253>\
**Category:** Support\
**Tags:** asset-optimization\
**Created:** [January 28, 2021, 8:27am UTC](https://answers.netlify.com/t/automatically-compress-served-content/31253 "2021-01-28T08:27:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhjngli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/zhjngli/32/18132_2.png) [@zhjngli](https://answers.netlify.com/u/zhjngli)\
**Post date:** [January 28, 2021, 8:27am UTC](https://answers.netlify.com/t/automatically-compress-served-content/31253/1 "2021-01-28T08:27:38Z")

</div>

I noticed that netlify doesn’t automatically compress some files that it should be able to, in particular .ttf, .woff2 fonts and .ico files. The browser I’m using has `accept-encoding: gzip, deflate, br`. I saw that other html files, js/css files, and .woff font files have been compressed with `br`, but why not the other files?

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [January 28, 2021, 9:14am UTC](https://answers.netlify.com/t/automatically-compress-served-content/31253/2 "2021-01-28T09:14:38Z")

</div>

Hi, @zhjngli. Would you please send us the actual URL which is being served incorrectly?

---

<div class="post-metadata">

**Author:** ![zhjngli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/zhjngli/32/18132_2.png) [@zhjngli](https://answers.netlify.com/u/zhjngli)\
**Post date:** [January 28, 2021, 9:22am UTC](https://answers.netlify.com/t/automatically-compress-served-content/31253/3 "2021-01-28T09:22:49Z")

</div>

oops, it’s at [https://zhjngli.com](https://zhjngli.com)  
thanks!

---

<div class="post-metadata">

**Author:** ![zhjngli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/zhjngli/32/18132_2.png) [@zhjngli](https://answers.netlify.com/u/zhjngli)\
**Post date:** [January 29, 2021, 7:17am UTC](https://answers.netlify.com/t/automatically-compress-served-content/31253/4 "2021-01-29T07:17:47Z")

</div>

Is there an update? Do you need a more specific url? thanks!

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [January 29, 2021, 8:32am UTC](https://answers.netlify.com/t/automatically-compress-served-content/31253/5 "2021-01-29T08:32:20Z")

</div>

Hi, @zhjngli. I see the response sent compressed when I test:

 ![screenshot](https://global.discourse-cdn.com/netlify/original/3X/1/4/148aa7d7747501442b23ecd7358a3ed5c3719668.png)

If you are not seeing compressed responses would you please send us an example of what you are seeing? If possible, a [HAR file recording](https://toolbox.googleapps.com/apps/har_analyzer/) of the issue happening would be ideal.

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [January 31, 2021, 9:43am UTC](https://answers.netlify.com/t/automatically-compress-served-content/31253/9 "2021-01-31T09:43:31Z")

</div>

You can send the recordings via any cloud storage.

But to weigh in, I think this is done on purpose to keeps websites fast. Essentially, compression and speed go in opposite ways. The more you have to compress, the more time you need, increasing the time to load the page. It’s because, Netlify compresses the assets when they’re requested and doesn’t store compressed assets because not every request accepts compressed assets.

So, text assets like HTML, CSS, JS are easily compressed. Even then I guess, they’re not compressed with Brotli level 11, they are stuck at 7 around I suppose, as further compressing would again increase time. But the other assets that you mention take more time to compress and with probably a million websites on Netlify and even if each website has 10 images, it would make 10 million images. Imagine compressing them on the fly for every request.

I might be wrong as these are just my assumptions.

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [February 1, 2021, 2:43am UTC](https://answers.netlify.com/t/automatically-compress-served-content/31253/10 "2021-02-01T02:43:51Z")

</div>

Hi, @zhjngli. Not all files can be compressed. This is a fundamental truth of data compression. There is an explanation here:

> [@Image optimization and compression on React sites](https://answers.netlify.com/t/image-optimization-and-compression-on-react-sites/20538/4):
>
> Hi, @lftoma, there is a thought experiment in data compression of: Can a single compression algorithm compress all files? As with all thought experiments the value is in solving the puzzle yourself but I’m going to reveal to the answer: No single compression algorithm can compress all files. Sometimes attempting to “compress” a file only makes it bigger. This is especially true for already compressed data and PNG files are already very well compressed. I’m rambling a bit. Why do I mention…

To summarize, files which don’t compress when compression is attempted, are not modified. In other words, if “compressing” will only make the file bigger (and, yes, that is what is happening) we won’t attempt to compress it.

Don’t believe me? Well, how about some proof! 😉 🙂

```plaintext
$ curl -o font.woff2 'https://zhjngli.com/fonts/hind-madurai-v6-latin-300.woff2' --compressed
$ ls -l font.woff2
-rw-r--r-- 1 luke staff 14040 Jan 31 18:38 font.woff2
$ brotli font.woff2
$ ls -l font*
-rw-r--r-- 1 luke staff 14040 Jan 31 18:38 font.woff2
-rw-r--r-- 1 luke staff 14045 Jan 31 18:38 font.woff2.br

```

The brotli compressed file is five bytes larger. (Which, again, is actually completely normal and expected behavior in the science of data compression.) The original font file size is 14040 and it is 14045 after compression with brotli.

Again, not all files can benefit from compressions (precisely because they are already highly compressed files). If that is the case, we won’t compress it.

If there are other questions or concerns, please let us know.
