Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Enable Brotli Compression on Your Linux VPS

Configure Brotli correctly on a Linux VPS with NGINX or Apache, including module loading, MIME rules, pre-compressed assets, curl verification, troubleshooting and TLS security guidance.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable Brotli at the web-server layer, not in your application code. On NGINX, install a Brotli filter module, load it, turn on brotli, select text MIME types, test the configuration, and reload NGINX. On Apache 2.4.26 or newer, load mod_brotli and attach its BROTLI_COMPRESS filter to the responses you want compressed. Verify the result with curl by checking for Content-Encoding: br and an appropriate Vary: Accept-Encoding header.

What Brotli does on a VPS

Brotli is a lossless HTTP compression format. A compatible browser advertises support with the Accept-Encoding request header; the server can then send a smaller representation and identify it with Content-Encoding: br. The browser decompresses the response before handing it to the page.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The useful targets are text-heavy responses: HTML, CSS, JavaScript, JSON, XML, plain text and SVG. JPEG, PNG, GIF, most video, ZIP files and other archives are already compressed, so applying Brotli usually spends CPU without producing a worthwhile reduction. Brotli is therefore a web-server configuration task with two separate implementation choices:

  • Runtime compression: the server compresses each response as it is requested. This is simple, but consumes CPU on every compression pass.
  • Pre-compressed delivery: your build or deployment process creates a matching .br file once, and the server serves it when the client supports Brotli. This avoids repeated compression work.

Use runtime compression first for a small, controlled set of text responses. Add pre-compressed delivery for static assets when your deployment process can reliably keep the original and .br files synchronized.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Choose the NGINX or Apache path

Decision point NGINX Apache
Required component A Brotli filter module; a static module is optional for serving pre-compressed files. mod_brotli, available in Apache 2.4.26 and later.
Enable compression brotli on; AddOutputFilterByType BROTLI_COMPRESS ... for selected types, or SetOutputFilter BROTLI_COMPRESS for broader scope.
MIME control brotli_types adds MIME types; text/html is compressed by default by the Google module. Put the MIME types you want after AddOutputFilterByType.
Pre-compressed files Use the static module and brotli_static on; when matching .br files are deployed. Configure delivery so the response carries Content-Encoding: br and caches vary on Accept-Encoding.
Validation and reload nginx -t, then nginx -s reload. Use your normal Apache configuration test and graceful-reload workflow after enabling the module; the exact service command depends on the VPS distribution.

Follow the section for the server that terminates HTTP or HTTPS traffic. If a reverse proxy sits in front of your application, configure Brotli on the component that actually sends the response to the client.

Enable Brotli in NGINX

1. Install a module that matches your NGINX build

Stock NGINX builds do not universally include Brotli. Install a module compiled for the exact NGINX distribution and version running on the VPS. F5’s NGINX Plus instructions show this Debian/Ubuntu example:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install nginx-plus-module-brotli

On a RHEL-family distribution, use the available yum or dnf package workflow and the module package supplied for that NGINX build. Do not copy a module from an unrelated NGINX version: a binary-module mismatch can prevent NGINX from starting. If your distribution does not provide a compatible package, use a vendor-supported build or compile the Google ngx_brotli module for your exact NGINX source and deployment process.

2. Load the dynamic modules in the main context

Place the module declarations in the main (top-level) context of nginx.conf, before the http block. The filter module is required for on-the-fly compression. Load the static module as well only if you will serve pre-compressed files:

load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;

The path is the one used in the documented NGINX Plus example. A package on your VPS may install the files in a different directory; use the paths delivered by that package. Loading a file that does not exist, or loading a module built for an incompatible NGINX version, will make nginx -t fail.

3. Turn on the filter and select text formats

Inside the http, server or location context, enable Brotli and list the additional MIME types you want compressed:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
brotli on;
brotli_types text/plain text/css application/javascript application/json application/xml image/svg+xml;

The Google module documentation states that text/html is always compressed and that brotli_types adds MIME types. The directive matches the response’s MIME type, so an application that labels a response incorrectly may not be compressed even when its contents are text.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Keep this list focused. JavaScript may be served as application/javascript or another JavaScript MIME type depending on your stack; add only types your server actually emits and have tested. Do not add image, video or archive types merely because they are large.

4. Enable static delivery only when .br files exist

For build-time compression, deploy files such as app.js and app.js.br together, then add:

brotli_static on;

This directive is useful only when matching pre-compressed files are generated during your build or deployment. It is not a command that creates them. If a requested asset has no valid .br counterpart, the normal uncompressed file (or runtime-compressed response, if configured) must remain available.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Test the syntax and reload without stopping the server

  1. Run the configuration test:
nginx -t

Proceed only when NGINX reports a successful syntax check. The error output identifies missing modules, invalid contexts and typographical errors.

  1. Ask NGINX to reload the validated configuration:
nginx -s reload

A reload lets existing workers finish while new workers use the updated configuration. Check the service and error logs immediately afterward for module-load or syntax errors. If the reload fails, restore the previous configuration and correct the reported line before trying again.

Enable Brotli in Apache

1. Confirm the Apache version and module

Apache HTTP Server 2.4.26 and later provide mod_brotli. The module supplies the BROTLI_COMPRESS output filter, which compresses server output in Brotli format before it is sent over the network. Install or enable the module using the package and module mechanism supplied by your Linux distribution, then confirm that Apache starts with it loaded. Package names and helper commands vary between distributions, so use the module package corresponding to your installed Apache version rather than copying a command for another operating system.

2. Compress selected MIME types (recommended starting point)

For Apache 2.4.26 and newer, attach the filter to text-oriented types:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript application/json

This approach limits compression to responses whose declared type is in the list. Add a type only after confirming that your application uses that type and that the response is not already compressed by another layer. SVG and other textual formats can be added when they are served as text and your deployment benefits from compressing them.

3. Use broad filtering only with explicit exclusions

Apache also documents a broader filter:

SetOutputFilter BROTLI_COMPRESS
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-brotli

The first line applies the filter broadly; the second shows the style of exclusion needed for common already-compressed images. A broad rule can catch binary downloads, archives or media that should not be recompressed, so a MIME-type allow-list is generally easier to audit. Extend exclusions for every non-text class your server delivers rather than assuming the example covers all of them.

4. Reload and inspect the logs

Run the Apache configuration test used by your distribution, then perform a graceful reload through its service manager. If Apache rejects the configuration, read the exact module, directive or syntax error in the test output and in the error log. A successful reload does not prove that a particular URL is compressed; verification must be done with a request that advertises Brotli support.

Runtime versus pre-compressed assets

Runtime compression

Runtime compression is convenient for generated HTML and API responses because the server can compress the current output without a separate build artifact. Its cost is CPU work on each compression pass. The cost depends on response size, Brotli quality settings, request volume and the VPS CPU; there is no single compression-ratio or latency percentage that applies to every VPS.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start with cacheable static text and ordinary pages. Monitor CPU, response time and cache behavior after enabling it. If a dynamic endpoint is CPU-bound, narrow the MIME list, reduce the endpoint’s response size or move stable assets to pre-compressed delivery instead of assuming that more compression is always faster.

Pre-compressed delivery

Apache’s documentation notes that mod_brotli recompresses content each time a request is made, and that pre-compressing content can provide a performance benefit by avoiding that work. A typical deployment creates .br files for CSS and JavaScript, publishes them beside the originals and configures the server to select them only for clients that advertise br.

The response must identify the representation correctly:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
  • Content-Encoding: br tells the client that the body is Brotli-compressed.
  • Vary: Accept-Encoding tells shared caches that compressed and uncompressed representations vary by the request’s encoding capability.
  • The uncompressed original must remain available for clients that do not send br.

Do not deploy a stale .br file after replacing its source asset. A stale compressed artifact can be served successfully while containing old code, which is a release-integrity problem rather than a compression problem.

Verify that the VPS returns Brotli

1. Request a known text asset with negotiation

Use an HTTPS URL for a CSS, JavaScript, HTML or JSON response that should be compressible:

curl -I -H 'Accept-Encoding: br' https://example.com/asset.css

In the response headers, look for:

  • Content-Encoding: br — the body is Brotli-compressed.
  • Vary: Accept-Encoding — important when a shared cache can store responses for multiple kinds of clients.
  • A suitable Content-Type — confirms that your MIME rule matches what the server actually emits.

An HTTP redirect, an application error, an upstream proxy response or a response with a non-text MIME type may not show Brotli even when the module is configured correctly. Follow the final URL and test an asset known to be served by the configured NGINX or Apache instance.

2. Check the non-Brotli path

Request the same resource without advertising br:

curl -I https://example.com/asset.css

The server should return an uncompressed body or another encoding supported by that client. It must not send a Brotli body to a client that did not negotiate it. If both requests return identical headers, inspect which process is terminating the connection and whether a proxy or cache is replacing the origin response.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Inspect logs and cache behavior

After a reload, review the web-server error log for module-load failures, unknown directives and permission errors. If the origin shows Content-Encoding: br but a client does not, inspect the reverse proxy and CDN headers. If a cache serves the wrong representation, verify that it honors Vary: Accept-Encoding and that compressed and uncompressed objects are not being keyed as one response.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

“unknown directive brotli” in NGINX

The filter module is not loaded, was not installed, or was built for an incompatible NGINX version. Confirm the module package, check the path in each load_module line and rerun nginx -t. Loading only the static module does not provide the brotli filter directive.

NGINX will not start after adding load_module

Run nginx -t before another reload. Correct a wrong file path, remove a module that your package does not provide, or install a module compiled for the running NGINX build. Do not repeatedly restart a production service while the syntax test is failing.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

The header lacks Content-Encoding: br

Check that the request includes Accept-Encoding: br, that the response is not a redirect or error, and that its MIME type matches your allow-list. For NGINX, remember that brotli_types adds types while text/html is handled by default by the Google module. For Apache, verify that the response type exactly matches one of the types in AddOutputFilterByType and that mod_brotli is loaded.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pre-compressed files are ignored

On NGINX, confirm that the static module is loaded and that brotli_static on; is in a context that covers the request. Confirm that the matching .br filename is deployed beside the original. On Apache, verify that the pre-compressed response is configured with Content-Encoding: br and that caches vary on Accept-Encoding; merely placing a file with a .br suffix does not automatically make every Apache configuration serve it.

CPU usage rises sharply

Runtime compression is being performed too often or at a costly quality setting. Restrict compression to text responses, exclude large or already-compressed content, cache stable assets and generate .br files during deployment. Measure the resulting CPU and response-time changes on your own workload rather than applying a published percentage that was measured on different hardware or content.

Security considerations for compressed HTTPS responses

Compression over TLS can create a BREACH-family information-disclosure risk for vulnerable applications. The risk is greatest when a response reflects attacker-controlled input alongside a secret, such as a CSRF token or other sensitive value, and an attacker can observe response-size changes across many requests. Apache’s documentation specifically warns that some web applications are vulnerable when a TLS connection carries compressed data.

Begin with static assets and ordinary text responses. Review pages that reflect secrets or sensitive tokens before enabling compression there. Possible mitigations include disabling compression for those responses, separating secrets from reflected content, reducing reflection of attacker-controlled data and applying the application’s established CSRF and session protections. Brotli itself does not create the application vulnerability; it can make a size side channel practical when the surrounding response design is unsafe.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A deployment checklist

  • Identify which service terminates HTTP or HTTPS and configure that service, not only the upstream application.
  • Install a Brotli module compatible with the exact NGINX or Apache build.
  • Limit runtime compression to text-like MIME types.
  • Exclude images, video, archives and other already-compressed formats.
  • Use brotli_static on; or an equivalent Apache pre-compressed setup only when matching .br files are generated and deployed with their originals.
  • For compressed responses, send Content-Encoding: br; for shared caches, send Vary: Accept-Encoding.
  • Run the server’s configuration test before reloading.
  • Verify with one request that advertises br and one that does not.
  • Review logs, CPU usage, cache behavior and sensitive-response exposure after rollout.

Practical rollout order

  1. Enable Brotli for a small set of static CSS and JavaScript files.
  2. Verify headers and the non-Brotli fallback with curl.
  3. Check that shared caches distinguish the two representations.
  4. Add HTML, JSON, XML or SVG only when their MIME types and security characteristics are understood.
  5. Move high-volume, stable assets to pre-compressed deployment if runtime CPU becomes material.
  6. Expand coverage gradually while watching logs, CPU and application responses.

This sequence separates configuration errors from application behavior and gives you a safe rollback point: remove the Brotli directives or stop deploying the static variants, then reload the validated configuration.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.