Pre-compress static website HTML and other assets
During my review of the new Tor websites (marble project) I noticed the developers included this little script in the repositories:
#!/bin/sh
set -e
find _site -type f -name "*.html" -o -name "*.css" -o -name "*.js" | while read file; do
brotli -kZ "${file}"
gzip -k9 "${file}"
done
I looked up why we would want to do this and found out that currently, out static-mirror web hosts compress data on-the-fly using mod_deflate
. We might be able to squeeze a bit of performance out of our hosts by pre-compressing HTML, CSS and JS assets and serving them to clients as-such. An example of the required configuration bits is available in the upstream docs: https://httpd.apache.org/docs/current/mod/mod_deflate.html#precompressed
I haven't made a thorough analysis of the potential benefits and drawbacks, but we might want to consider it at some point. However, if we decide to implement it, the compression should be handled at deploy-time, (eg. in static-shim-deploy.yml) instead of at build-time.