django-compression-middleware icon indicating copy to clipboard operation
django-compression-middleware copied to clipboard

Changing Brotli Compression Level

Open Duoquote opened this issue 4 years ago • 4 comments

Is there a way to change the brotli compression level?

Duoquote avatar Jan 14 '21 13:01 Duoquote

At the moment it is hard-coded to a fixed value (4). I've found this to give pretty good benefit for the cost. Maybe you had a different use-case in mind?

friedelwolff avatar Jan 24 '21 18:01 friedelwolff

I was planning to compress 80megabytes of data and sacrifice a few megabytes to gain speed from compression, it gets compressed to 7 megabytes but takes some time to compress.

Duoquote avatar Jan 31 '21 09:01 Duoquote

That is indeed an interesting case. Is this a streaming response? If we know the size beforehand, we could increase the compression level. In the streaming case, we don't know the size, so can't use such a simple heuristic.

friedelwolff avatar Feb 05 '21 17:02 friedelwolff

No, I want to decrease the compression level to gain speed from compression, my cpu struggles from compression but the bandwidth is ok with that.

Duoquote avatar Feb 05 '21 17:02 Duoquote