caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.53k stars 3.91k forks source link

Add support for `prefer_precompressed` to FileServer #6284

Open 3v0k4 opened 2 months ago

3v0k4 commented 2 months ago

Fixes #5116

Todos:

CLAassistant commented 2 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

3v0k4 commented 2 months ago

@francislavoie @mholt

This is still a spike as I'm trying to understand how we want to approach this before I do things properly.

Currently, I added a couple of if preferPrecompressed before the normal flow: the first one checks directly for the compressed file according to the client's accepted encodings and the second one looks for all the possible compressed files and, if one is found, uncompresses it.

I left the rest of the code because it takes care of the index files and browse. But we may want to consolidate things a bit more.

Would you be willing to share some feedback please?

mholt commented 1 month ago

Thanks for working on this -- I'll try to get around to this after the 2.8 release :)