-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Add ZLIB compression support #4080
base: master
Are you sure you want to change the base?
Conversation
Congrats on this PR, I definitely think it's useful to have zlib in encode/decode string functions. On the topic of compression, what would be your opinion on giving servers the option of serving their resources in 1 or more zips that get decompressed by the client? This would save bandwidth and reduce download times, it would likely be a more efficient method of caching server resources. |
External web server with gzip support is the most efficient solution in my opinion. Internal http server is old and inefficient. If we want to implement compression of client side cache files on server level then I recommend creating pre-compressed versions (.gz) on resource check and serving it via internal http server (it already supports gzip / deflate decompression). |
This pull request adds zlib data compression and decompression support.
Functions (shared): encodeString / decodeString
New algorithm: zlib
Optional arguments:
gzip
,zlib
,raw
or window size number (default = gzip);default
,filtered
,huffman
,rle
,fixed
.Returns:
Encoded / decoded string or zlib error code.
If no arguments are passed then encodeString will use
gzip
with highest compression level (9) and decodeString will try to automatically determine compressed format (wrapper).For most use cases there is no reason to change compression (the size difference is negligible; 0 = no compression).
Strategy is a low-level option which based on documentation might tune compression algorithm to get better results in some cases. I tested it on different data types and the size difference is not significant or might be worse than default option.
Note
Please note that the header (wrapper) size for
gzip
is 18 bytes and only 6 bytes forzlib
(so it's more compact).raw
(deflate) has no wrapping at all and usually used by programs to read / write .zip files.Tip
Quick testing (runcode):
Test resource: zlib.zip