MicroWebSrv
MicroWebSrv copied to clipboard
Added support for serving pre-compressed static files
If the request has the Accept-Encoding
header, will look for files in webPath that are pre-compressed with the specified encoding(s) before falling back to the file without any compression. Sets the Content-Encoding
header in the response appropriately.
For example, a request for /main.js
with the Accept-Encoding
header set to gzip, br
will look for files in this order: main.js.gz
, main.js.br
, then main.js
, No compression is done on the fly. main.js.gz
should already be compressed with gzip and MicroWebSrv trusts this: it responds with the file as-is, setting the Content-Encoding
header so that browsers will properly decode.
I'm using this to put only pre-compressed static files (HTML, CSS, Javascript) on my ESP32 to save a considerable amount of space. Also helps with performance as less data is transferred.
Thank you for this pull request :) I'll see that in few days!
Any news about this pull request? I would certainly appreciate this functionality in MWS2
Hello @ElHyperion, I'll see that for MWS2 and respond to your mails as soon :) 👍
Is this project abandoned? What's with the 3+ year delay on including this extremely essential feature?
@gitcnd; I believe it is. The readme now links to a new repo, MicroWebSrv2: https://github.com/jczic/MicroWebSrv2 I haven't tried that myself yet.
I merged your changes into my fork - tested - works great!! Thanks for the awesome code :-)
https://github.com/gitcnd/MicroWebSrv
I also added a minified version (cuts the size in half - to just 18kb) which works as well
I only tested brotli (I don't care about the lesser compression of gzip)
MicroWebSrv2 looks interesting, but it's an incredible amount of bloat and seems to require a whole pile of extra files.
I am using it with this: https://github.com/vsolina/micropython-web-editor - and I'm pretty sure that replacing the web server with MicroWebSrv2 would end up breaking something anyhow...