Support brotli compression of assets

Created on 23 November 2020, almost 4 years ago
Updated 30 January 2023, almost 2 years ago

Problem/Motivation

Drupal supports compressing aggregated assets with gzip.
It would be nice to also support brotli, since it provides better performances.

advagg provides this functionality but only on non-aggregated files.

Proposed resolution

AssetDumper could be patched to also create brotli files.

Remaining tasks

I will submit a patch.

User interface changes

A new option will need to be added to /admin/config/development/performance.

✨ Feature request
Status

Needs work

Version

10.1 ✨

Component
Asset libraryΒ  β†’

Last updated about 4 hours ago

No maintainer
Created by

πŸ‡«πŸ‡·France prudloff Lille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    Custom Commands Failed
  • last update over 1 year ago
    Custom Commands Failed
  • πŸ‡³πŸ‡±Netherlands JesperN

    Added rerolls of patch #20 and the non-`.htaccess` version of #22 on Drupal 10.1.x.

  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    So taking a look at this

    Could we add it's own test case? Seems some tests had to be updated for it but not sure if it's actually testing.

    Since the schema is updating most likely will need an upgrade path + upgrade path tests.

    If this new setting is required (which seems to be) it will require a change record also

    Thanks!

  • πŸ‡«πŸ‡·France andypost

    What if new compression algo will be added to browsers?

    Better to deprecate "gzip" option in favor of "compress" which will be common trigger to produce all possible assets archives.
    Also it could be a sequence of algo to limit :

    compress:
    - gzip
    - brotli
    
    +++ b/core/lib/Drupal/Core/Asset/AssetDumper.php
    @@ -77,6 +77,16 @@ public function dumpToUri(string $data, string $file_extension, string $uri): st
    +    if (extension_loaded('brotli') && \Drupal::config('system.performance')->get($file_extension . '.brotli')) {
    
    +++ b/core/modules/system/config/install/system.performance.yml
    @@ -4,6 +4,7 @@ cache:
     css:
       preprocess: true
       gzip: true
    +  brotli: false
    
    @@ -12,4 +13,5 @@ fast_404:
     js:
       preprocess: true
       gzip: true
    +  brotli: false
    

    Not sure it makes sense to introduce new configuration and without UI, it could re-use "gzip" setting to produce compressed assets using gzip/brotli

  • πŸ‡¬πŸ‡§United Kingdom catch

    A compress item with a sequence sounds good.

    Having said that we've got the problem that the .htaccess rules can't be configured - they will always need to check in order of likelihood-of-support first. So if we add brotli support to htaccess but it's disabled by the site, the rewrite rules will still look for those files.

    Makes me wonder if we should just do 'compress' as a boolean and write out everything we possibly can.

  • πŸ‡³πŸ‡±Netherlands JesperN

    Added rerolls of patches in #24 on Drupal 10.2.x. I think they should also apply on 11.x-dev.

  • πŸ‡³πŸ‡±Netherlands JesperN

    Added rerolls of patches in #29 on Drupal 10.2.x.

  • πŸ‡³πŸ‡±Netherlands JesperN
  • πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

    Is there a variable we can set in settings.php?

  • πŸ‡«πŸ‡·France andypost

    Not sure how tests can cover it but CR should mention update of nginx conf as well

  • Pipeline finished with Failed
    18 days ago
    Total: 110s
    #323298
Production build 0.71.5 2024