gzip vs zstd vs brotli

Percentage of compression of OpenBSD-www files.

size of OpenBSD-www files

How long does it take to compress all files in OpenBSD-www files?

size of OpenBSD-www files

How to compress all the files in /var/www/htdocs?

Makefile

HTDOCS != find /var/www/htdocs -type f ! -path "*/CVS/*" ! -name '*.gz' ! -name '*.br' ! -name '*.zst'
GZDOCS = ${HTDOCS:S/$/.gz/}
BRDOCS = ${HTDOCS:S/$/.br/}
ZSDOCS = ${HTDOCS:S/$/.zst/}

.PHONY: all gz br clean

all: gz br zst
gz: ${GZDOCS}
br: ${BRDOCS}
zst: ${ZSDOCS}

clean:
.for file in ${GZDOCS} ${BRDOCS} ${ZSTDOCS}
	rm -f "${file}"
.endfor

.for file in ${GZDOCS}
${file}:
	gzip -k ${file:R} || [ $$? -eq 2 ]
.endfor

.for file in ${BRDOCS}
${file}:
	brotli -kf ${file:R}
	if [ $$(stat -f %z ${file}) -ge $$(stat -f %z ${file:R}) ]; then rm ${file}; fi
.endfor

.for file in ${ZSDOCS}
${file}:
	zstd -k ${file:R}
	if [ $$(stat -f %z ${file}) -ge $$(stat -f %z ${file:R}) ]; then rm ${file}; fi
.endfor