We’re always looking for ways to help you squeeze every bit of performance out of your Clarive instance. That’s why we now recommend enabling both Brotli and Gzip compression in your NGINX configuration. With these two working in tandem, your web assets will be delivered faster, using less bandwidth—and your users will thank you for the speed boost!


Why Enable Both Brotli and Gzip?

  • Brotli often achieves better compression ratios than Gzip, especially on text-based assets like CSS, JavaScript, and HTML.
  • Gzip has universal support across all browsers and proxies.
  • By enabling both, you get the best of both worlds: modern browsers will pick Brotli, and older clients will fall back to Gzip.

Step-by-Step: Update Your nginx.conf

  1. SSH into your Clarive server.
  2. Backup your existing configuration:
    cp /opt/clarive/config/nginx/nginx.conf /opt/clarive/config/nginx/nginx.conf.bak
    
  3. Open the file in your favorite editor:
    vi /opt/clarive/config/nginx/nginx.conf
    
  4. Locate the http { … } block near the top of the file.

  5. Paste the following lines inside the http { section, just below any existing include or log_format directives:
http {

   # -------------------------------------------------------------------
   # Clarive: Enable Brotli & Gzip Compression
   # -------------------------------------------------------------------

   brotli              on;
   brotli_static       off;   # 'on' only if you have pre-compressed files
   brotli_comp_level   4;
   brotli_types        text/plain text/css text/javascript text/js 
                       text/xml application/json application/javascript
                       application/x-javascript application/xml
                       application/xml+rss application/x-font-ttf 
                       image/svg+xml font/opentype
                       font/woff font/woff2 font/woff3 
                       application/x-font-woff;

   gzip               on;
   gzip_min_length    8000;              # only compress responses ≥8KB
   gzip_comp_level    5;                 # compression level (1–9)
   gzip_proxied       any;               # compress even when via a proxy
   gzip_types         text/plain
                      text/css
                      application/json
                      application/javascript
                      application/xml
                      text/xml
                      image/svg+xml;      # MIME types to compress
   gzip_vary          on;                 # add “Vary: Accept-Encoding”
   gzip_buffers       16 8k;

   # ... the rest of your http section ...
}
  1. Save the file and exit your editor.
  2. Test the new configuration and reload NGINX:

    nginx -t && systemctl reload nginx
    
  3. Or use the Clarive nginx server restart if Nginx runs from Clarive itself
    cla nginx-restart -c YOURCONFIG
    

Verify Your Compression

After reloading, you can quickly check that Brotli and Gzip are working:

# Brotli test (modern browsers)
curl -H "Accept-Encoding: br" -I https://your-clarive-domain.com \
  | grep -i content-encoding

# Gzip test (fallback)
curl -H "Accept-Encoding: gzip" -I https://your-clarive-domain.com \
  | grep -i content-encoding

You should see content-encoding: br for Brotli and content-encoding: gzip for Gzip.


Need Help?

If you hit any snags—or just want to chat about other optimizations—our support team is here for you. Drop us a line at [email protected] or open a ticket via the Clarive portal.

Happy compressing! 🚀