Added support for serving pre-compressed static files #56
+63
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theContent-Encoding
header in the response appropriately.For example, a request for
/main.js
with theAccept-Encoding
header set togzip, br
will look for files in this order:main.js.gz
,main.js.br
, thenmain.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 theContent-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.