Alorel / shrink-ray

Node.js compression middleware
MIT License
177 stars 16 forks source link

Cache: only re-encode if maximum quality wasn't used originally #54

Open OliverJAsh opened 4 years ago

OliverJAsh commented 4 years ago

It seems that this module will asynchronously re-encode at the best/maximum quality, even if the maximum quality was used originally. IIUC, this means that if you ask for the maximum quality, shrink-ray will end up compressing the resource twice at the maximum quality.

I think we need to add a guard around the re-encode, so that it only runs if maximum quality wasn't already used:

https://github.com/Alorel/shrink-ray/blob/f7cfcc7d5cf5d31ed8deadbfd717f80e64585a8c/index.js#L411-L422

OliverJAsh commented 4 years ago

Hi @Alorel would you accept a PR to fix this?