View Issue Details

IDProjectCategoryView StatusLast Update
2670Composrcorepublic2022-08-15 15:47
ReporterChris Graham Assigned ToChris Graham  
PrioritynormalSeverityfeature 
Status resolvedResolutionfixed 
Summary2670: Support Brotli compression
DescriptionBrotli compression, which is very new, may present roughly 20% improvement over gzip.

It isn't yet supported by PHP or Apache (https://en.wikipedia.org/wiki/Brotli), but when it is, we should support it as an automated upgrade from gzip compression for those users that can run it (Firefox, Chrome - but we look at the Accept-Encoding header). I don't think it needs to be configurable.
TagsType: Performance
Attach Tags
Time estimation (hours)4
Sponsorship open

Sponsor

Date Added Member Amount Sponsored

Activities

Chris Graham

2019-09-30 22:35

administrator   ~6098

Brotli is similar to gzip, but uses an inbuilt dictionary optimized for web traffic.

"Javascript files compressed with Brotli are 14% smaller than gzip. HTML files are 21% smaller than gzip. CSS files are 17% smaller than gzip."

There is a PHP extension we can support:
https://github.com/kjdev/php-ext-brotli

We can also try our .htaccess trick of serving pre-heavily-compressed .br files directly if the browser accepts them, like we currently do with .gz.

Chris Graham

2019-11-27 19:55

administrator   ~6188

Last edited: 2019-11-27 19:57

Interesting/relevant note - Brotli is HTTPS-only. This is because they figure proxies will cache Brotli content served under HTTP and cause all kinds of bugs for UAs not supporting it.

Chris Graham

2019-12-10 23:57

administrator   ~6217

Last edited: 2019-12-11 02:27

Also see https://github.com/kjdev/php-ext-zstd
EDIT: While zstd (aka zstandard) is gaining adoption, and is by a web company, it is not itself designed as an HTTP compression scheme, and nobody is picking it up as such.

Chris Graham

2019-12-11 18:31

administrator   ~6219

Last edited: 2019-12-11 21:38

This is now implemented. It does not depend on Apache or PHP supporting Brotli, as I've taken a different approach. The old gzip option is now an output compression option, and you can select to output Brotli (which falls back to gzip if needed). If there's no PHP support for Brotli it will encode via shell_exec to the brotli executable (EDIT: but not for the main HTML output, as you cannot set an output_filter to a user-defined function or set one at run-time, and output buffers are not appropriate for implementing compression as they may process multiple times).

Issue History

Date Modified Username Field Change
2016-06-19 17:05 Chris Graham New Issue
2016-06-19 17:05 Chris Graham Tag Attached: Type: Performance
2017-04-08 14:44 Chris Graham Description Updated
2019-06-27 19:23 Chris Graham Summary Support Brotli compression (holding issue) => Support Brotli compression (on hold)
2019-09-30 22:35 Chris Graham Note Added: 0006098
2019-09-30 22:35 Chris Graham Summary Support Brotli compression (on hold) => Support Brotli compression
2019-11-14 22:04 Chris Graham Tag Attached: Roadmap: v12
2019-11-27 19:55 Chris Graham Note Added: 0006188
2019-11-27 19:57 Chris Graham Note Edited: 0006188
2019-12-10 23:57 Chris Graham Note Added: 0006217
2019-12-11 02:27 Chris Graham Note Edited: 0006217
2019-12-11 18:31 Chris Graham Assigned To => Chris Graham
2019-12-11 18:31 Chris Graham Status Not Assigned => Resolved
2019-12-11 18:31 Chris Graham Resolution open => fixed
2019-12-11 18:31 Chris Graham Note Added: 0006219
2019-12-11 21:38 Chris Graham Note Edited: 0006219
2022-08-15 15:47 Chris Graham Tag Detached: Roadmap: v12