File_server - new compress option

The “encode” directive is encoding every file every time there is a request, seems like there should be an option to save encoding for future requests, file_server has “precompressed” option but you have to do all the compressing yourself, I think file_server should add new option “compress” with good defaults on auto compressing and saving compressed file, any thoughts on this?

Hi @M_S,

Personally, I don’t think Caddy is the most correct tool for this. It’s kind of a run-once functionality rather than a server configuration, per se. It’s very easy to write a script to do this to your exact specification instead.

You could even configure Caddy to run your script (or even a find -exec command directly) on startup, if you wanted, with GitHub - abiosoft/caddy-exec: Caddy v2 module for running one-off commands.

2 Likes

Or, you could use a caching mechanism like GitHub - caddyserver/cache-handler: Distributed HTTP caching module for Caddy which can cache the responses to the files (which includes them being compressed) which could save a bit of CPU cycles. (The plugin might still have some rough edges for now, but it’s being worked on.)

2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.