Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for serving pre-compressed static files #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

camlee
Copy link

@camlee camlee commented Jun 22, 2019

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.

@jczic
Copy link
Owner

jczic commented Jul 6, 2019

Thank you for this pull request :)
I'll see that in few days!

@ElHyperion
Copy link

ElHyperion commented Feb 10, 2020

Any news about this pull request? I would certainly appreciate this functionality in MWS2

@jczic
Copy link
Owner

jczic commented Feb 10, 2020

Hello @ElHyperion,
I'll see that for MWS2 and respond to your mails as soon :)
👍

@gitcnd
Copy link

gitcnd commented Oct 28, 2023

Is this project abandoned? What's with the 3+ year delay on including this extremely essential feature?

@camlee
Copy link
Author

camlee commented Oct 28, 2023

@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.

@gitcnd
Copy link

gitcnd commented Oct 28, 2023

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants