Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Brotli Pre-compression for Only One Account

Discussion in 'EasyApache' started by Alec Dean, May 21, 2019.

  1. Alec Dean

    Alec Dean Registered

    Oct 23, 2017
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hi Guys...

    I'd like to enable Brotli pre-compression for just one of my accounts who will actually be taking the time to manually Brotli compress their static assets. In reference to this thread: Using Brotli to pre-compress content, I'm clear that the general pre-compression entry needs to be added to the WHM >> Apache Configuration >> Pre VirtualHost Include section. What I'd like to know is if I could use an approach similar to the one seen here: mod_brotli - Apache HTTP Server Version 2.5 Where the compression is restricted to a particular directory to also limit the pre-compression to just one account? Something like:
    <Directory "/home/account_name/public_html">              
        <IfModule mod_headers.c>
            # Serve brotli compressed CSS and JS files if they exist
            # and the client accepts brotli.
            RewriteCond "%{HTTP:Accept-encoding}" "br"
            RewriteCond "%{REQUEST_FILENAME}\.br" "-s"
            RewriteRule "^(.*)\.(js|css)"              "$1\.$2\.br" [QSA]
            # Serve correct content types, and prevent double compression.
            RewriteRule "\.css\.br$" "-" [T=text/css,E=no-brotli:1]
            RewriteRule "\.js\.br$"  "-" [T=text/javascript,E=no-brotli:1]
            <FilesMatch "(\.js\.br|\.css\.br)$">
              # Serve correct encoding type.
              Header append Content-Encoding br
              # Force proxies to cache brotli &
              # non-brotli css/js files separately.
              Header append Vary Accept-Encoding
    If so, is <Directory> tag recursive? Will this directive apply to any and all content in the public_html directory and/or any of its subdirectories?

  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hello @Alec Dean,

    You can edit the file below to modify the default configuration settings for mod_brotli:


    Then, rather than globally enabling your custom entry for all accounts via the use of the Apache Pre VirtualHost Include, you could instead add the custom entry to the individual VirtualHost of a specific domain using the instructions documented on the link below:

    Modify Apache Virtual Hosts with Include Files - EasyApache 4 - cPanel Documentation

    Additionally, you may want to vote for the feature request below:

    Configure Brotli per-account

    Let me know if this helps.

    Thank you.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice