Added support for serving pre-compressed static files#56
Added support for serving pre-compressed static files#56camlee wants to merge 1 commit intojczic:masterfrom
Conversation
|
Thank you for this pull request :) |
|
Any news about this pull request? I would certainly appreciate this functionality in MWS2 |
|
Hello @ElHyperion, |
|
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 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... |
If the request has the
Accept-Encodingheader, 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 theContent-Encodingheader in the response appropriately.For example, a request for
/main.jswith theAccept-Encodingheader set togzip, brwill look for files in this order:main.js.gz,main.js.br, thenmain.js, No compression is done on the fly.main.js.gzshould already be compressed with gzip and MicroWebSrv trusts this: it responds with the file as-is, setting theContent-Encodingheader 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.