#GZIP Support?
1 messages · Page 1 of 1 (latest)
A lot of the libs i've found haven't been maintained in a very long time...
compress-nio does support gzip i think?
Ahhhh sweet, will give this a go thanks for that my man
Note that gzip request and response compression is also built into vapor, just check app.http.server.configuration for the options
@azure crypt Ahhh ok so i can see that there's a ResponseCompressionConfiguration & RequestDecompressionConfiguration options on the configuration, if i enable both of these. Set the headers on my request and response. This should do the trick no?
Yep
Though note that request compression needs to be set from the sending side, and is relatively rare to see (unless you control both ends)
Will i need to handle it on the FE (within my iOS app) as well before i make/send the request? Or will these headers handle it all for me
You can set it after — the server reads the headers to see if the client is sending a compressed request and behaves accordingly
So add support to your server first via those options, then enable in your client to get the savings
Note that incompressible types (ie. images, video, etc…) will just end up wasting CPU time on the server side, so there are some sane defaults to make sure only things like JSON are compressed, leaving other types untouched
Ahhh ok so I was planning to actually use this on images 😅
You won't get much savings, and you'll use CPU time, fair warning 😅
(this is from experience)
Loooool ok, really appreciate you breaking this down btw @azure crypt
Last thing i want is to affect CPU time, so might just stick with what I have now then
I would definitely enable it for things like JSON though — there its a win win, as the CPU time is negligent compared to the time saved sending the compressed bytes
Yh i'll look into it for my JSON for sure. Again thanks for your help and explaination @azure crypt. As someone who doesn't have a lot of backend experience stuff like this is really valuable to me
This is the configuration default you want: https://api.vapor.codes/vapor/documentation/vapor/httpserver/configuration-swift.struct/responsecompressionconfiguration/enabledforcompressibletypes
tunds gave a
to @azure crypt, who now has 109
!
Though I think enabled will also do the right thing — they only differ in how they handle unknown types: https://api.vapor.codes/vapor/documentation/vapor/httpserver/configuration-swift.struct/responsecompressionconfiguration/enabled