Last active
December 5, 2022 16:24
-
-
Save ptudor/90b44c72997580af9baada6e1554a871 to your computer and use it in GitHub Desktop.
two ways to use brotli compression in Apache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quick hints for using brotli compression in Apache, available since 2.4.26 | |
# | |
# method one is for inline proxies with AddOutputFilterByType. | |
# method two is for static local files with FilesMatch/SetOutputFilter | |
# | |
# ptudor 2019 | |
############################# | |
# /etc/httpd/conf.d/10-mod_deflate_proxy.conf | |
<If "%{HTTP:Accept-Encoding} =~ /br/"> | |
<IfModule mod_brotli.c> | |
AddOutputFilterByType BROTLI_COMPRESS text/css application/javascript text/javascript text/html text/plain text/xml text/csv application/json | |
</IfModule> | |
</If> | |
<ElseIf "%{HTTP:Accept-Encoding} =~ /gzip/"> | |
<IfModule mod_deflate.c> | |
AddOutputFilterByType DEFLATE text/css application/javascript text/javascript text/html text/plain text/xml text/csv application/json | |
</IfModule> | |
</ElseIf> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quick hints for using brotli compression in Apache, available since 2.4.26 | |
# | |
# method one is for inline proxies with AddOutputFilterByType | |
# method two is for static local files with FilesMatch/SetOutputFilter | |
# ptudor 2019 | |
############################# | |
# /etc/httpd/conf.d/11-mod_deflate_static.conf | |
<FilesMatch "\.(js|html|htm|css|csv|json|xml)$"> | |
<If "%{HTTP:Accept-Encoding} =~ /br/"> | |
<IfModule mod_brotli.c> | |
SetOutputFilter BROTLI_COMPRESS | |
</IfModule> | |
</If> | |
<ElseIf "%{HTTP:Accept-Encoding} =~ /gzip/"> | |
<IfModule mod_deflate.c> | |
SetOutputFilter DEFLATE | |
</IfModule> | |
</ElseIf> | |
</FilesMatch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment