koajs / compress

Compress middleware for koa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

compress = true ignored when below treshold

jesperp opened this issue · comments

Although docs says

You can always enable compression by setting this.compress = true

Mistake in docs or code? :)

It should ignore threshold. Does it not?

no, this.compress is not checked

if (threshold && this.response.length < threshold) return

https://github.com/koajs/compress/blob/master/index.js#L63

@jesperp see https://github.com/koajs/compress/blob/master/index.js#L55
and https://github.com/koajs/compress/blob/master/index.js#L44

this.compress does not force compression below the threshold. It merely bypasses the filter, or enables on a file-by-file level.

gotcha

@jesperp Apologies, let me correct myself, that should have been below the threshold.

i.e. the threshold is for files that are too small to bother with.