The gzip directive operates early on in the middleware chain, but it simply swaps out the default ResponseWriter for a gzipWriter so anything written by later middleware such as ipfilter is compressed.
When a browser receives a compressed file without a content type, it can’t make the assumption that it’s HTML intended to be rendered, so it downloads it instead. I’d wager that’s the cause of your problem.
I'll quote this post made by Matthew Fay on the Caddy support forum here, since I'm not really familiar with this codebase: