On Apache, we need to prevent double-compression by mod_brotli (in addition to mod_deflate). See https://httpd.apache.org/docs/2.4/mod/mod_brotli.html

If mod_brotli is enabled and active for text/css and text/javascript, a Drupal site's precompressed CSS and JS cannot be loaded by the browser (Failed to load resource: net::ERR_CONTENT_DECODING_FAILED) so I'm classifying this as a bug rather than feature request.

CommentFileSizeAuthor
#2 3023545-mod_brotli.patch742 bytesmfb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mfb created an issue. See original summary.

mfb’s picture

Ayesh’s picture

Issue tags: +Apache

I had Brotli enabled all my servers but never ran into this problem because I was compressing everything on the fly and didn't use pre-compressed gzip files (additional disk access didn't outweigh compression overhead).

To provide more information to others, this problem occurs only if you serve pre-compressed Brotli or Gzip files with a rewrite rule. Enabling Brotli with a filter (for example with AddOutputFilterByType BROTLI_COMPRESS application/json) does not double-encode the response.

If you serve .gz files with a rewrite rule, the patch fixes it. I call we can mark this RTBC if a few others can confirm.

d13r’s picture

The patch worked for me - thanks.

andypost’s picture

Btw advagg allows it, so better to add support for it to core

Anybody’s picture

Status: Needs review » Reviewed & tested by the community

Patch from #2 works perfectly and solved it equally to Drupal 8. We should get this in as long as Drupal 7 is still maintained. Thank you all!

Here you can find the committed Drupal 8 patch / issue: #2960808: Disable brotli compression of pre-compressed CSS and JS

mcdruid’s picture

Issue tags: +Pending Drupal 7 commit

LGTM.

Would be good to combine this in the same release as any other .htaccess changes we're working on (e.g. #2768921: Backport server configuration code from SA-CORE-2016-003 to Drupal 7)

Fabianx’s picture

RTBC + 1

  • mcdruid committed 4ff644d on 7.x
    Issue #3023545 by mfb: Disable brotli compression of pre-compressed CSS...
mcdruid’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Pending Drupal 7 commit

Thankingyou!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.