coreybutler / fenix

A simple and visual static web server with collaboration features.
https://preview.fenixwebserver.com
GNU General Public License v3.0
1.65k stars 135 forks source link

Brotli Compression #125

Open coreybutler opened 3 years ago

coreybutler commented 3 years ago

Files which are pre-compressed with Brotli compression are not serving the appropriate compression headers. The file itself is served, but browsers do not decompress it when the HTTP header isn't present.

coreybutler commented 3 years ago

Brotli compression cannot be reliably detected on files at runtime. According to this study, there is a 95% false positive ratio, meaning practically nothing can be trusted. Brotli does not have identifying bytes, so attempting to automate this will be buggy at best. This differs from gzip compression, which does have identifying bytes (and could therefore be detected).

An alternative solution would be maintaining a list of files (or filename patterns, http route patterns, etc) which are pre-compressed. This list could be referenced at runtime, applying the appropriate HTTP response headers for brotli-compressed files. A lookup like this adds latency to response times, but it would be minimal and unperceivable. Most major object storage platforms (like S3) do something similar.

The alternative solution could be an option, similar to other runtime processing options.