# Compress text-based responses.
# Primary path: explicit FilterChain matching Content_Type — applies correctly
# even when responses come from PHP-FPM via mod_proxy_fcgi, where the legacy
# AddOutputFilterByType is sometimes skipped. AddOutputFilterByType is kept as
# a secondary safety net inside the same mod_filter guard (the directive
# itself is provided by mod_filter on Apache 2.4+). mod_deflate skips itself
# when Content-Encoding is already set, so no risk of double compression.
<IfModule mod_filter.c>
FilterDeclare be_compress
<IfModule mod_brotli.c>
FilterProvider be_compress BROTLI_COMPRESS "%{Content_Type} =~ m#^text/(html|plain|xml|css|javascript|x-component)#i"
FilterProvider be_compress BROTLI_COMPRESS "%{Content_Type} =~ m#^application/(javascript|x-javascript|json|xml|atom\+xml|rss\+xml)#i"
FilterProvider be_compress BROTLI_COMPRESS "%{Content_Type} =~ m#^image/svg\+xml#i"
</IfModule>
<IfModule mod_deflate.c>
FilterProvider be_compress DEFLATE "%{Content_Type} =~ m#^text/(html|plain|xml|css|javascript|x-component)#i"
FilterProvider be_compress DEFLATE "%{Content_Type} =~ m#^application/(javascript|x-javascript|json|xml|atom\+xml|rss\+xml)#i"
FilterProvider be_compress DEFLATE "%{Content_Type} =~ m#^image/(svg\+xml|x-icon)#i"
FilterProvider be_compress DEFLATE "%{Content_Type} =~ m#^font/(otf|ttf)#i"
</IfModule>
FilterChain be_compress
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE font/ttf font/otf
</IfModule>
<IfModule mod_brotli.c>
AddOutputFilterByType BROTLI_COMPRESS text/html text/css text/javascript
AddOutputFilterByType BROTLI_COMPRESS application/javascript application/x-javascript application/json application/xml
AddOutputFilterByType BROTLI_COMPRESS image/svg+xml
</IfModule>
</IfModule>
